Hello,
I wanted to know how do I detect when a song has stopped playing since the IsPlaying function is not working as it should. So if I a song was no longer playing how would I find this out? (P.S I'm not going to use :Stop() since it's a automatic switching system). So how would I do it?
Thanks Pkamara
IsPlaying tells you if a song is playing
Example:
1 | --assuming the script is in the sound |
2 | if script.Parent.IsPlaying = = false then |
3 | print ( "This audio is not playing!" ) |
4 | else |
5 | print ( "This audio seems to be playing" ) |
So when a song starts/stops, this becomes true/false, which you can use to trigger events base on audio, or to have a new song play if you have a song playlist you have for your game.
As for your question, if IsPlaying doesn't work correctly, I would time the audio, and have the script wait before playing it again. But I'm not sure why IsPlaying would not work. How is it not working? Explain a little more.
Based on your reply to the previous answer im going to assume you want a script to wait until a song is finished to play the next one. So here's my best answer based on that information
this is if the script is inside a model containing multiple songs
1 | local songs = script.Parent:GetChildren() |
2 | while wait() do |
3 | for i = 1 , #songs do |
4 | songs [ i ] :Play() |
5 | repeat |
6 | wait() |
7 | until not songs [ i ] .IsPlaying |
8 | end |
9 | end |