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

Making a music script use a table???

Asked by
hokyboy 270 Moderation Voter
3 years ago
Edited 3 years ago
local Sound = script.Sound
local ContendProvider = game:GetService("ContentProvider")

local MaxSound = 2

local CurrSound = 0

local Music = {
    551334045,
    1524396093,
    627848963,

}




while true do
    if CurrSound <= MaxSound then
        Sound.SoundId = "rbxassetid://"..Music[CurrSound]
        CurrSound = CurrSound + 1
        Sound:Play()
        Sound.Ended:Wait()
    else
        CurrSound = 0
    end
end

i tried making this music script and im new to tables can someone explain to me what i did wrong

Output error / Players.ExternalSight.PlayerGui.MusicScript:20: attempt to concatenate string with nil  

1 answer

Log in to vote
1
Answered by 3 years ago

Ah. CurSound has to be greater than 0. You're trying to get the 0th string in the table.

1
Ah my bad i tought tables started at 0 instead of 1 hokyboy 270 — 3y
Ad

Answer this question