Sound.Ended is broken

local sound = Instance.new("Sound",workspace)
game.Debris:AddItem(sound,5)
sound.SoundId = "rbxassetid://502022490"

sound:Play()
sound.Loaded:Wait()
print("loaded")
wait(1)
sound.Ended:Connect(function()
	print("ended")
end)
sound:Stop()
print("stopped")

Output:

loaded
stopped

Doesn’t work in game or in studio on both client and server.

AFAIK :Ended is called when the sound actually ends, not when it’s stopped. So your result seems like expected behavior.

Maybe you want to use the :Stopped event instead?

3 Likes

as mentioned above, you want to use the .Stopped event for this

if you want to make the same things happen on both stopping the sound and when the sound ends, you can just do this

function DoThings()
    print("stopped or ended")
end

sound.Stopped:Connect(DoThings)
sound.Ended:Connect(DoThings)
4 Likes

@PressurizedSphere according to Documentation - Roblox Creator Hub

This event will fire whenever the sound has ended playing, either because :Stop() was called on the sound or the end of the sound was reached.

Interesting. Not sure if that’s the intended behavior or just an incorrect description.

Would definitely prefer if the current behavior is kept though, since it gives an easy way to know when the sound actually finishes playing. If you need a to do something when the sound either stops or ends, using two events like @PressurizedSphere suggested seem pretty simple.

1 Like

If the current behavior is not kept, it will be impossible to tell if a sound Ended or Stopped. I agree with keeping the existing behavior and changing the wiki documentation.

3 Likes

Yeah that description of it firing when Stop is called is inaccurate.
Ended fires when a sound finishes its playback without any intervention.
The event isn’t broken, it’s just described incorrectly.
cc @UristMcSparks @cowbear16

3 Likes

Gonna push this, as it’s been 4 years and this is still broken :face_with_raised_eyebrow:

Have you tried using Sound.Stopped instead?

Review the responses above, the answer is already given, no need to bump.

Feel free to file a documentation request in #bug-reports:developer-hub . Marking solution and closing.