Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why can't I detect if a sound has ended?

I've previously posted this same question but none of the answers really had results. I have tried to approach this situation two ways and they work in studio but not ingame. Using local scripts and even server scripts, neither of them were successful in running through the game.

.Ended:

script.Song.Ended:connect(function()
print("Song has ended!")
end)

TimePosition and TimeLength

if script.Song.TimePosition >= script.Song.TimeLength - 5 then
	if script.Song.TimePosition > 5 then
	print("Song has ended!")
	end
end

Both work in studio, neither works ingame.

2 comments

0

You shouldn't put the song inside the script

0

That won't solve anything

1 answer

✓ Accepted answer

The Server doesn't play sounds
Something about chew toys

Because the server never loads a sound, it doesn't know when it has ended or how far into the sound it is. As a result, you'll need to move your code to a LocalScript because sounds are only loaded and played on the client.

This discussion is preserved as it was. New answers, comments, and votes are closed.