So basically, I've been making a game and I've added a script which adds multiple songs instead of one. So, when I test out the game, the music starts but they ALL start at once. Sound1 is located in the workspace, sound2 is inside sound1, sound 3 inside sound2 so on so forth, anyways, here's the script:
local sound1 = 2529519176 local sound2 = 500155118 local sound3 = 1930853637 local sound4 = 1468374269 local music = script.Parent while true do wait() music.SoundId= "rbxassetid://"..sound1 music:Play() music.Ended: wait() music.SoundId= "rbxassetid://"..sound2 music:Play() music.Ended: wait() music.SoundId= "rbxassetid://"..sound3 music:Play() music.Ended: wait() music.SoundId= "rbxassetid://"..sound4 music:Play() music.Ended: wait() end
well; you could try this:
local music = script.Parent local current_index = 1 local songs = { 2529519176; 500155118; 1930853637; 1468374269; } music.SoundId = "rbxassetid://"..songs[current_index]; music:Play() music.Ended:Connect(function() if songs[current_index+1] then current_index = current_index+1; else current_index = 1; end music.SoundId = "rbxassetid://"..songs[current_index]; music:Play() end)
it just listens for when one song ends and plays the next one in the array (if there is one present) otherwise , it just returns at the first one in the array
this will allow you to end more songs without having to write any code
hello, im in a bad mood, so this will not be a really god answer, but you could just find how long each song is, then write (for example- if song a is 500 long and b is 30 long)then)
while true do a:Play() wait(500) b:Play() wait(30) end
but if you really wanted ur way, then i think the problem is no parenthesis. it probably should be
music.SoundId= ("rbxassetid://"..sound1) music:Play()
instead of
music.SoundId= "rbxassetid://"..sound1 music:Play()