I am making a music script and I can’t figure out how to detect when the currently playing sound ends. Here is a snippet from my script:
chosen:Play() -- A defined Sound
print("Music has started.") -- Prints
repeat wait(3) until chosen.Playing == false
print("Music has ended.") -- Doesn't print
As you can see in the comments from the code snippet above, the second print statement does not execute; however, the first print statement does execute. I tried using this as well but the same problem occured:
chosen:Play() -- A defined Sound
print("Music has started.") -- Prints
chosen.Ended:Wait()
print("Music has ended.") -- Doesn't print
That’s what it’s supposed to do. However, when the sound ends, Sound.Ended:Wait() keeps infinitely yielding. And no, the sound is not being deleted at any point during this process.
Nevermind, I found out that it somehow wasn’t triggering the Ended event because I was skipping the song (changing the timeposition of the sound). Thanks anyway @doytnr