Table only chooses ONE color

My script only chooses ONE color when I try to make the color of an NPC’s torso a randomized color from a table. What’s what’s wrong with my script?

local bodycolor = script.Parent

local colorstbl = {"Dusty Rose", "Neon orange", "Bright yellow"}
local color = colorstbl[math.random(0,#colorstbl)]

bodycolor.TorsoColor = BrickColor.new(color)

Try this:

local colorstbl = {"Dusty Rose", "Neon orange", "Bright yellow"}
local color = colorstbl[math.random(1,#colorstbl)]
print(color)
3 Likes

I think the output was nil since you started with a 0

prints correctly, but when the body color is changed, it continues to change to orange.

okay i guess it works now? it just favors the color orange for some reason

You could try using Random.new() to achieve “more” randomness

Regarding the “randomness”:

1 Like