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

When I run this in game it stops halfway through the first song, can someone help me?

Asked by 7 years ago
local S1 = Instance.new("Sound")
    S1.Name = "Music"
    S1.SoundId = "http://www.roblox.com/asset/?id=154988842"
    S1.Parent = game.Workspace
local S2 = Instance.new("Sound")
    S2.Name = "Music"
    S2.SoundId = "http://www.roblox.com/asset/?id=181462247"
    S2.Parent = game.Workspace
local S3 = Instance.new("Sound")
    S3.Name = "Music"
    S3.SoundId = "http://www.roblox.com/asset/?id=181462282"
    S3.Parent = game.Workspace

local S4 = Instance.new("Sound")
    S4.Name = "Music"
    S4.SoundId = "http://www.roblox.com/asset/?id=181462320"
    S4.Parent = game.Workspace


local S5 = Instance.new("Sound")
    S5.Name = "Music"
    S5.SoundId = "http://www.roblox.com/asset/?id=181462345"
    S5.Parent = game.Workspace

while true do
    wait()
    S1:Play()
    S1.Ended:wait()

    S2:Play()
    S2.Ended:wait()

    S3:Play()
    S3.Ended:wait()

    S4:Play()
    S4.Ended:wait()

    S5:Play()
    S5.Ended:wait()

end

1 answer

Log in to vote
0
Answered by
cabbler 1942 Moderation Voter
7 years ago

This is really easy to test and it works fine. Needs some organization. Always loop!

local ids = {154988842,181462247,181462282,181462320,181462345}

local sounds = {}

for _,id in ipairs(ids) do
    local new = Instance.new("Sound")
    new.SoundId = "http://www.roblox.com/asset/?id="..id
    new.Parent = workspace
    table.insert(sounds,new)
end

while wait() do
    for _,s in ipairs(sounds) do
        if not s.IsLoaded then s.Loaded:wait() end
        s:Play()
        s.Ended:wait()
    end
end
Ad

Answer this question