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

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

Asked by
Acheo 230 Moderation Voter
8 years ago

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.

0
You shouldn't put the song inside the script User#11440 120 — 8y
0
That won't solve anything Acheo 230 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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.

Ad

Answer this question