Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with BrickColor math.random?

Not working

Colors = {"Pearl", "Toothpaste"}
game.Workspace.aaa.BrickColor = BrickColor.new(math.random(1, #Colors))

1 answer

✓ Accepted answer

#Why does it not work? You are setting the color of the brick to the value 1 to 2. It works fine, it's just that you're not actually using tables correctly. Everything works fine though.


#How do you fix it? When using a table, you try to address a value inside like this Table[1]. Table being the table, and the number next to it being which value in the table to choose.


#Final Product

Colors = {"Pearl", "Toothpaste"}
game.Workspace.aaa.BrickColor = BrickColor.new(Colors[math.random(1, #Colors)]) --Very small change. Added: "Colors[...]"


Hope it helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.