Still have questions? Join our Discord server and get real time help.
Log in to vote

How to use IsPlaying?

Asked by 6 years ago


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

2 answers

Log in to vote
Answered by 6 years ago

IsPlaying tells you if a song is playing


--assuming the script is in the sound
if script.Parent.IsPlaying==false then
print("This audio is not playing!")
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.

Since I have a table full of random songs to play and it does all the random stuff then it finishes but never does IsPlaying ever == false GameAnnounce 3 — 6y
Try timing it, and see how long until each song is over? Thats what I did when audios in my game were like that. Tempestatem 879 — 6y
Okay. GameAnnounce 3 — 6y
Log in to vote
Answered by
Marolex 45
6 years ago

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

local songs = script.Parent:GetChildren()
while wait() do
for i = 1, #songs do
until not songs[i].IsPlaying

Answer this question