PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Change a Part's Color using BrickColor

Change a Part's Color using BrickColor

Jun 23 2018, 10:21 AM PST

Problem

You want to use BrickColors.

Solution

Use the BrickColor table.

local part = Instance.new('Part')
part.Parent = Workspace
part.Anchored = true
part.BrickColor = BrickColor.random()

Discussion

Where do these brick colors come from? If you’ve ever set the color of a brick in Studio you’ll notice that there is a little widget that comes up with a bunch of colors you can choose from. That’s all the BrickColors. If you hover over a color you’ll notice that a tooltip comes up with its name. That name can be put into BrickColor.new and you’ll have that color. Also, notice that the colors are in some sort of order. This same order can be achieved by using the BrickColor.palette function. Since the first color on the widget is “Br. yellowish green”, then BrickColor.palette(0) would be equal to BrickColor.new(“Br. yellowish green”).

You can also convert a BrickColor to a Color3 by accessing BrickColor.Color. You can also access individual components of the Color3 directly from the BrickColor with BrickColor.r, .g, and .b. Do note these are read-only values.

Tags:
  • part
  • color