I have this script that has Sound as a parent of it. It's supposed to play music but however, it doesn't work at all!

function play(id)
    script.Parent.SoundId = "rbxassetid://"..id
    script.Parent:Play()
    script.Parent.Ended:wait()
end



while wait() do
    local musicTable = {142304703, 142304778, 142304968, 142305080, 142305170}


    for i = 1, #musicTable do 
        local Random = musicTable[math.random(1, #musicTable)]
        play(musicTable[Random])
        table.remove(musicTable, Random)
    end
end

Why doesn't it work?

2 comments

0

Because the loop is going so fast, it's constantly playing new ID's every "wait()". Try making it wait for the current song to finish.

0

Nothing happens still, it doesn't even work.