Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to use IsPlaying?

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

2 answers

IsPlaying tells you if a song is playing

Example:

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

3 comments

0

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

0

Try timing it, and see how long until each song is over? Thats what I did when audios in my game were like that.

0

Okay.

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
songs[i]:Play()
repeat 
wait()
until not songs[i].IsPlaying
end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.