How do I apply colors from a table?

local PresentColors = {BrickColor.new(253, 234, 141), BrickColor.new(82, 124, 174)}

Cart.Present.BrickColor = PresentColors[math.random(1, table.getn(PresentColors))]

That’s what I have but it just goes to white.

You should be using Color3.fromRGB() as it would be a value from 0-255

Color3.new()
Part.Color

--not

BrickColor.new()
Part.BrickColor

I’m assuming this function returns the length of a table (i’ve never seen it before), but you can just do

#PresentColors

It would do the same thing.

1 Like

Usually to Apply Colors from a table you do this:

local Colors = {
[1] = Color3.fromRGB(253, 234, 141),
[2] = Color3.fromRGB(82, 124, 174)
}

Cart.Present.Color = Colors[math.random(1,#Colors)]

}

The Numbers on the table aren’t important tho

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.