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

What am i doing wrong here?

Asked by 8 years ago

I am not very experienced with i,v pairs but i want to be able to start using them. It makes scripting easier and more organized. This is what i tried and it doesn't work, can someone tell me exactly what I'm doing wrong

songs = {"rbxassetid://236764932","rbxassetid://145154345","rbxassetid://202376551"}

local folder = Instance.new("Folder",player.PlayerGui)

for i,v in pairs(songs)do
    print(v)
    song = Instance.new("Sound")
    song.Parent = folder
    song.Volume = 1
    song.SoundId = v
    song:Play()
    wait(song.TimeLength)
    song:Destroy()
    wait()
end


plz help me................................

0
You have to give us the output for us to help. yumtaste 476 — 8y
0
player isn't defined YellowoTide 1992 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

There are two issues with your script. The first is you never defined what/who player was. Secondly, you can not call on song.TimeLength. as it returns 0. To test this, just do wait(song.TimeLegth), it returns as 0. Here is the fixed script that plays the music in the folder.

game.Players.PlayerAdded:connect(function(player)
    local songs = {"rbxassetid://236764932","rbxassetid://145154345","rbxassetid://202376551"}
    local folder = Instance.new("Folder", player.PlayerGui)

for i,v in pairs(songs)do
    wait()
    print(v)
    local song = Instance.new("Sound", folder)
    song.SoundId = v
    song.Volume = 1
    song:Play()
    wait(90) --Because you can't wait the TimeLength, you just have to wait 90 seconds (the Length of the first song played)
    song:Destroy()
    wait()
end
end)
Ad

Answer this question