Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to chain music together?

Asked by 9 years ago

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

Log in to vote
0
Answered by
Defaultio 160
9 years ago

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.

0
Thanks I will try this out and let you know if it works. :) CrystalCoder 20 — 9y
0
Is it possible to get the length of the song through MarketplaceService? Nickoakz 231 — 9y
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 Defaultio 160 — 9y
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? CrystalCoder 20 — 9y
0
I have just managed to fix the IsPlaying thanks for the help! CrystalCoder 20 — 9y
Ad

Answer this question