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

Find out when a Sound has stopped playing?

This is the most obnoxious thing I've ever had experienced so far, because It's so simple yet it doesn't work in any way I attempt to perform it.

Basically, I'm making a Script that fires an event to a localscript inside the local player, which plays a sound that the localplayer can only hear, it uses an array of sounds to go through 1 by 1 playing each song until they STOP PLAYING, then it reccures from the next song, etc etc

I've literally tried almost every method I could think of, including what people from the Forums told me to try, the methods I've tried either work in studio, or not function at all. The only way I've actually been able to continue the script is to remove code that waits for the Sound to be finished playing, and that actually works... so I know for a fact that the rest of the code works perfectly, It's literally this one line of code which I described multiple times.

Sorry for the big wall of text

function playSong(song)
	song:Play()
	ChangeSongEvent:FireAllClients(song)
	song.Ended:connect(function() --works in studio, never called in a Server for some reason
		playSong(nextSong())
	end)
end

Methods I've tried:

repeat wait() until not song.IsPlaying
song.Changed:connect(function(c)
	if c == "IsPlaying" then
		--go on
	end
end)
song.Ended:connect(function()
	--go on
end)

also I've tried coroutines, but not extremely familiar with them.

Is there literally no way to see when a Sound has stopped playing or has ended?

Help would be greatly appreciated

2 comments

0

Stopped is never called, the script is fully automatic, no user input

1 answer

May this helps:

wait(Sound.TimeLength)  --This waits the time of how long the sound goes.

1 comment

0

No, TimeLength is only readable in studio, in the server you can't read it.

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