I’ve been trying to figure out how to stop sounds played with play local sound and can’t seem to find the answer.
The function actually plays the object itself, so you could control it with the :Pause() or :Stop() methods. At least that’s what the doc implies
https://developer.roblox.com/en-us/api-reference/function/SoundService/PlayLocalSound
Unfortunately, unless I’m doing something wrong, this doesn’t seem to be the case.
What you need to do is just like @HumanMop said - You create a Sound then Play it using SoundService, If you want to stop the Sound, Then you just need to use the Pause method on the sound. (Or any other methods, Such as Stop)
-- Assuming you have the Sound Instance
local SoundService = game:GetService("SoundService")
SoundService:PlayLocalSound(Sound)
task.delay(3, function()
Sound:Stop()
end)
That didn’t work either. The sound continues to play even after :Stop() is called.
I think PlayLocalSound is specifically meant for playing short plugin sound effects in the circumstance of a Team Create server instance such that the other studio clients won’t hear the sound, but that’s just speculation. My suggestion is to just use a different means of playback, like the standard :Play() call.
Your sound should be in the SoundService folder.
And then change the definition too in your script for the new location.
The documentation implies that the sound instance used by PlayLocalSound() should behave like any other sound instance: SoundService:PlayLocalSound i.e. Stop() should work.
Therefore, this is an engine bug which I documented in more detail here: PlayLocalSound() issues - e.g. Ended not firing - engine bug or incorrect usage? Alternatives for playing sounds locally?
I have reported it and so far ROBLOX have said they can replicate the issue.