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

How to chain music together?

Hi I need some help linking music together but I don't know how to this. I need to make each one play as soon as the other one finishes. I have already got it ready to shuffle the songs.

1 answer

✓ Accepted answer

You can use the .IsPlaying property of sound to let the script yield until the current song is finished. So if you've got a table of songs, you could do something like

songs = { ... }
for _, song in pairs(songs) do
	song:play()
	while song.IsPlaying do
		wait()
	end
end

to iterate through each song in the list and play them each through.

5 comments

0

Thanks I will try this out and let you know if it works. :)

0

Is it possible to get the length of the song through MarketplaceService?

0

Not that I'm aware of. However, if you've got some time beforehand, you could find out using something like function getLength(sound) local startTime=time() sound.Volume=0 sound:play() while sound.IsPlaying do wait() end return time()-startTime end

0

I have been working on this over the last couple of days and it is skipping while sound.IsPlaying do wait() and it isn't waiting, even when it says wait(50) it doesn't wait for 50 seconds?

0

I have just managed to fix the IsPlaying thanks for the help!

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