Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is there a way to check if a Sound has finished playing?

Asked by 10 years ago
-- Here's the Assets

Assets = {151602622,151758509,143550410,142544487,154072002,150558724,147096633,143620887,148263609,142851579,154237445,142991813,152318857,142301307,157890927,144803449,148324182,146541462,160535179,154741433,142856192,162596497,144003396,144195439,145546010,152536688,162660508,145143628,146058363,148567163,142318459,163404486}

-- Script in question

NoMore = 0
repeat
if Song.IsPlaying == false then
Song.SoundId = "rbxassetid://" ..Assets[math.random(1,#Assets)]
Song:Play()
end
wait(1)
until NoMore == 1

Using IsPlaying only checks to see if someone had stopped or paused the song. If the song goes all the way through without stopping, it will always stay as IsPlaying. Is there another way to check when the sound has stopped?

2 answers

Log in to vote
1
Answered by 10 years ago

The reason is that there have been changes to the sound engine recently. Sounds will always be 'playing' unless told to stop, and the reason for that is that because the client has to load sounds, they wanted everyone to hear the sound, even if not at the perfect moment (this resolved the bug of 'my sounds don't play half the time' along with 'sounds don't play the first time they are used').

Unfortunately, with this, they broke IsPlaying. You'll simply have to have a list of sound lengths as well, and then wait that amount of time and then manually call Stop on the sound.

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

im pretty sure you can just replace isPlaying with Ended and replace the false in front of that with true ( in line 9 for example :
randomsong.Ended == true then

this could work, then again, im still a bit new to roblox scripting, and im guessing you got it fixed.....

Answer this question