I'm not sure how to do it, but I tried both methods. Can someone help me find what's wrong? By the way, the script is inside a ServerStorage model named MusicHolder
SCRIPT NUMBER ONE
local musicholder = script.Parent
local music = musicholder:GetChildren()
local time1 = game.ServerStorage.MusicHolder.CW.TimeLength
local time2 = musicholder.DeckDubstep.TimeLength
local time3 = musicholder.EhDe.TimeLength
local time4 = musicholder.JayKode.TimeLength
local time5 = musicholder.Ookay.TimeLength
local time6 = musicholder.SantaComes.TimeLength
local time7 = musicholder.XmasToMe.TimeLength
local randomsong = math.random(1, #music)
while true do
wait(1)
musicholder:WaitForChild("CW","DeckDubstep", "EhDe", "JayKode", "Ookay", "SantaComes", "XmasToMe")
wait(7)
if randomsong == 1 then
musicholder.CW:Play()
wait(time1)
end
if randomsong == 2 then
musicholder.DeckDubstep:Play()
wait(time2)
end
if randomsong == 3 then
musicholder.EhDe:Play()
wait(time3)
end
if randomsong == 4 then
musicholder.JayKode:Play()
wait(time4)
end
if randomsong == 5 then
musicholder.Ookay:Play()
wait(time5)
end
if randomsong == 6 then
musicholder.SantaComes:Play()
wait(time6)
end
if randomsong == 7 then
musicholder.XmasToMe:Play()
wait(time7)
end
end
SCRIPT NUMBER TWO
local musicholder = script.Parent
local music = musicholder:GetChildren()
local randomsong = math.random(1, #music)
local cw = musicholder.CW
local dd = musicholder.DeckDubstep
local ehde = musicholder.EhDe
local jk = musicholder.JayKode
local okay = musicholder.Ookay
local sc = musicholder.SantaComes
local xmas = musicholder.XmasToMe
while true do
wait(7)
if randomsong == 1 then
cw:Play()
if cw.Stopped == true then
end
end
if randomsong == 2 then
dd:Play()
if dd.Stopped == true then
end
end
if randomsong == 3 then
ehde:Play()
if ehde.Stopped == true then
end
end
if randomsong == 4 then
jk:Play()
if jk.Stopped == true then
end
end
if randomsong == 5 then
okay:Play()
if okay.Stopped == true then
end
end
if randomsong == 6 then
sc:Play()
if sc.Stopped == true then
end
end
if randomsong == 7 then
xmas:Play()
if xmas.Stopped == true then
end
end
end

2 comments
Could you please tell us what is exactly happening?
um im attempting to choose a random song with math.random but songs dont even play at all :| i play the song and wait until the end then choose another song randomly