For years, I've been using a really simple AppleScript to reset Music's AirPlay device back to my computer. I trigger it using a keyboard shortcut from the Music → Scripts menu:
tell application "Music"
set newAirplayDevice to (get some AirPlay device whose kind is computer)
set current AirPlay devices to {newAirplayDevice}
end tell
Lately (after upgrading to macOS 14, I think) I trigger it through Music, I get an "AppleEvent timed out" error. However, the script still works as intended when I run it from Script Editor. This limits my ability to troubleshoot. Does this indicate there is a flaw in the script, or is it something in my system configuration?