PlayLocalSound() issues - e.g. Ended not firing - engine bug or incorrect usage? Alternatives for playing sounds locally?

I’ve been having a lot of issues with PlayLocalSound().

local tool = script.Parent
local SoundService = game:GetService("SoundService")

local function onActivated()
	print("activated")
	local sound = Instance.new("Sound")
	sound.SoundId = "rbxassetid://10088482556"
	sound.Looped = false -- this did not resolve any issues
	SoundService:PlayLocalSound(sound)
	sound.Ended:Wait()
	print("ended")
end

tool.Activated:Connect(onActivated)

For example, in the function above, Ended:Wait() will yield forever - “ended” is never printed. I believe Ended is supposed to fire for PlayLocalSound usage too, as shown here: SoundService:PlayLocalSound.

  • What is causing this?
  • Is there a different way of checking if the local sound has ended? (see attempted solutions below)
  • If not, is there an alternative to playing sounds on the client which does not involve PlayLocalSound()?

I have tried:

  • Setting Looped to false
  • Connecting Ended to a function (does not fire still)
  • Using Stopped instead (does not fire either)
  • Doing wait(sound.TimeLength) also isn’t working as an alternative solution. This is due to another issue: TimeLength is always 0.
    • Sound.TimeLength says that this zero value is due to the sound not being loaded. However, ANOTHER issue is that waiting for the sound to load (as shown in the documentation) causes an infinite yield too.

Other issues:

  • sound:Stop() does not stop the local sound
  • Tried using sound:Destroy() as a workaround, but this also doesn’t work.
  • Don’t think changing the sound volume works either.
  • TimeLength 0 value and Loaded:Wait() infinite yield (as mentioned above)

If my usage is correct and other people can replicate this issue then I guess I will post this in bug reports.

Many thanks in advance.

9 Likes

Bumping this since I can’t post in bug reports.

Here’s a place file demonstrating the Ended event issue. I removed the code relating to the tool. It simply plays a sound in StarterPlayerScripts. That’s it. And the issues above still occur - at least for me.
PlayLocalSound_IssueDemo.rbxl (34.1 KB)

Bumping this, since the issue persists.

To play a sound locally, you should not be using PlayLocalSound(). Instead, you should play sounds via a LocalScript using the normal :Play() method.

I believe PlayLocalSound() should only be used for plugins. It is poorly documented.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.