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.
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.