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

How to make a script which plays a random song after one has finished?

So basically, I'm trying to get a script to play a song, when the game starts, then once that has finished, I want it to play a different song, picked randomly from a list. So how would I do that? I've gotten the basics of the loops, but only of one song. Can someone help please?

ID = '317251079' -- Music ID
Looped = true -- False for Non-Looping Music

Music=Instance.new("Sound" ,Workspace)
Music.Name = "Music"
if Looped == true then
Music.Looped = true
end
Music.SoundId = "http://roblox.com/asset/?id=317251079" -- Music ID
Music:Play()

2 answers

✓ Accepted answer
local musicTracks = {
	"http://roblox.com/asset/?id=317251079",
	"add more"
}

music = musicTracks[math.random(1,#musicTracks)]
music:Play()

2 comments

0

Thx! I'll try to test it out. I see how it works now.

0

Yeah, it works now, when I add this in. Thx again.

local musicPlaylists = {
"http://roblox.com/asset/?id=317251079",
" add more"
}
Music.Ended:(connect(function()

Music.SoundId = musicPlaylists[math.random(1,#musicPlaylists)]
Music:Play()
end)

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