Ad
Log in to vote
0

Making a music script use a table???

Asked by
hokyboy 250 Moderation Voter
3 months ago
Edited 3 months 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 months 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 250 — 3mo
Ad

Answer this question