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

Problems with Sounds any help?

Asked by
Ryzox 220 Moderation Voter
9 years ago

Okay so me and a friend were going to make a script that cycles through music in a game and searches for any models called "Screen" in workspace and a block called "-" inside it which has a surfacegui and textlables. Here is a picture of how it is laid out: Picture

Okay so what we're having trouble with is getting it to work ingame. It works perfectly in studio, but as soon as we test ingame, it just loops the 1st song and doesn't move on, is this a fault on ROBLOX's side or are we doing something wrong in the script? If so please could you point it out. Here is the script:

Music = {}

function AddMusic(Name, id)
    table.insert(Music, {Title=Name,ID=id});    
end

Musica = true

AddMusic("Uptown Funk",210232032)
AddMusic("Blank Space",200481071)
AddMusic("Centuries",181547615)
AddMusic("Sugar",212017208)
AddMusic("Like I Can Remix",195112281)
AddMusic("Gravity Falls - 8 bit",156026545)
AddMusic("Elector Monster",169875502)

coroutine.resume(coroutine.create(function()
    while Musica do
        Musica = false
        for i,v in pairs(Music) do
            local Sound = Instance.new("Sound",workspace)
            Sound.Archivable = true
            Sound.SoundId = "http://www.roblox.com/asset/?id="..v.ID
            for _,Screen in pairs(workspace:children()) do
                if Screen:IsA("Model") and Screen.Name == "Screen" and Screen:findFirstChild("-") then
                    Screen["-"].SurfaceGui.Frame.Cur.Text = "Current Song: "..v.Title
                    if Music[i+1] then
                        Screen["-"].SurfaceGui.Frame.Nex.Text = "Next Song: "..Music[i+1].Title
                    else
                        Screen["-"].SurfaceGui.Frame.Nex.Text = "Next Song: "..Music[1].Title
                    end
                end
            end
            Sound.Volume = 1
            Sound.Looped = true
            wait()
            Sound:Play()
            Sound.DidLoop:wait()
            Sound:Stop()
            Sound:Destroy()
        end
        Musica = true
        wait()
    end
end))

Yes I know there is no point in it being inside a coroutine, but I added it just in case I wanted to add anything else into the script later, or if my friend wanted it. It's the exact same without the coroutine.

0
cmon like 2 hours and still no help x.x Ryzox 220 — 9y
0
Line 23:- Sound.SoundId = "http://www.roblox.com/asset/?id="..v.ID ?? should it be just Sound.SoundId = "http://www.roblox.com/asset/?id="..v User#5423 17 — 9y
0
How so? i'm not having any troubles playing the right song Id and it should be v.ID why would it be v? Ryzox 220 — 9y
1
It shouldn't be just 'v' because 'v' is a table and 'ID' is inside the table > v.ID ImageLabel 1541 — 9y

1 answer

Log in to vote
0
Answered by
Wizzy011 245 Moderation Voter
9 years ago

I tried doing this a while back, sadly there is no easy way of doing such a thing. The only way you can get a song to change after it's finished/looped is to use it locally inside a player. ROBLOX can't comprehend this Server-Side because players may start playing the song at different moments.

So my answer is, it is partially ROBLOX's fault, but you can possibly run the whole thing locally if you wanted, and it would work.

Ad

Answer this question