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

What's wrong with my random music chooser?

Asked by
Relatch 550 Moderation Voter
10 years ago
music = {176407800, 166886402, 183503743, 185698490}

while true do
    local id = math.random(1, #music)
    script.Sound.SoundId = "rbxassetid://"..id
    wait(10)
end

It doesn't do anything and I have no errors. What did I do wrong?

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Your problem is on line 5 of that code.

The value of id is either 1, 2, 3, or 4. These correspond to the four ids you have in the music table, but you have to actually access the table to get them. :P

script.Sound.SoundId = "rbxassetid://" .. music[id]
0
Oh.. lol Relatch 550 — 10y
0
Hmm, still doesn't seem to work. Relatch 550 — 10y
0
Oh, because I didn't play it. XD Relatch 550 — 10y
Ad

Answer this question