Heya,
For a Jukebox I’m creating, I need a way to detect when a sound stopped playing. Since there’s no specific event that fires once this happens, I made one myself:
function ChangedEvent()
if Debounce == 0 then
if Sound.IsPlaying ~= true then
Debounce = 5
MusicStoppedPlaying()
end
end
end
function MusicStoppedPlaying()
if NextPart == true then
print("Starting part 2")
StartSong(CurrentlyPlaying)
elseif NextSong ~= 0 then
print("Starting next song")
StartSong(NextSong)
NextSong = 0
else
print("Starting a random song")
StartSong(math.random(1,#MusicList))
end
end
Sound.Changed:connect(ChangedEvent)
while true do
wait(1)
--print(Debounce)
if Debounce > 0 then Debounce = Debounce-1
else Debounce = 0
end
end
This function works like it should, but it doesn’t trigger. Apparently, the IsPlaying property doesn’t return to false once a sound stops playing (Bug?).
(I tested this without the script too, so I doubt I’m breaking it myself)
Is there another way for me to detect once a sound stops playing? As far as I know, making a automatic jukebox is impossible without a working IsPlaying property.