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

The music script will only play the first song. Can someone help me find the problem?

Asked by
xAdxn 2
5 years ago

Only the first song is playing, none of the other songs are playing. Here's the link to the script: https://pastebin.com/d4dLg6Ji Picture line 4 as a straight line.

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Well that's because you can only set a single Id to a sound instance, to fix this we can loop over each id and create its own sound instance.

local sounds={"rbxassetid://144997651" ,"rbxassetid://279206904" ,"rbxassetid://279207008" ,"rbxassetid://3264735520" ,"rbxassetid://2943261339" ,"rbxassetid://212675193" ,"rbxassetid://2636748467" ,"rbxassetid://1617737624" ,"rbxassetid://3127092399" ,"rbxassetid://1616301680" ,"rbxassetid://160442087" ,"rbxassetid://3180460921"  }

for _,sound in pairs(sounds) do
    s = Instance.new("Sound")
    s.Pitch = 1
    s.Volume = 1
    s.SoundId = sound
    s.Looped = false
    s.PlayOnRemove = true
    s.Parent=workspace
    s:Play()
    repeat wait() until s.TimeLength>0
    wait(s.TimeLength)
end
0
Once I put that script in, it started to play all the songs at once. I want them to be able to be played one-by-one. xAdxn 2 — 5y
0
@xAdxn edited answer DanzLua 2879 — 5y
0
@DanzLua Samething is happening, xAdxn 2 — 5y
0
@xAdxn try now DanzLua 2879 — 5y
0
Works now. xAdxn 2 — 5y
Ad

Answer this question