Context: I have the function “playMoneyNotification()” below (used inside a local script, of course). The function is being fired via a remote event, via a (server-side) function - let’s call this Function A. Also, note that: Function A is being invoked by a remote function.
The Issue: with this configuration, the sound is not playing, and there are no error messages. “playMoneyNotification()” is being called though.
It seems that this issue is being caused by the fact that Function A is being executed due to a remote function call. When firing the aforementioned remote event from a context that does not include this remote function call, everything works; the sound plays as expected.
What causes this? Is it something to do with thread safety (SoundService:PlayLocalSound)? Or, perhaps an engine bug? And finally, is there any work around?
Feel free to ask for additional details if my explanation does not make sense. Many thanks in advance.
Note: the audio asset used below is not public yet as it is pending moderation.
local function playMoneyNotification()
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9798727907"
spawn(function() sound.Ended:Wait() end)
RESOLVED: It appears that when launching multiple clients on studio, sound only plays for the window for that respective player/client. E.g. when launching a server with 2 clients, if the window for Player1 is selected, only sound for Player1 will be heard. Note: I am using Windows 10 - not sure if this applies to other OSs.
The reason why this was only occurring in the ‘remote function context’ mentioned above is because this context involved e.g. sending money to another player, which initiates a sound effect for the receiving player. I did not have this player’s window selected, as I was sending money from the other player.
Not sure whether this is a bug, or an intentional design choice to stop sound from ‘spamming’ due to loads of client sessions. Nevertheless, this led to a lot of confusion.