BrickColor

< Scripting | Data Types

A BrickColor value is a specific color value. They are used instead of Color3 values on bricks and other 3D objects. Each BrickColor has a numeric id, that represents the color. For example, 1 is white, and 45 is a light blue. There are many different colors available: see the list here.

Contents

[edit] Using BrickColor codes

There are actually two ways to use BrickColor codes, the number code and the color code.

Each code has an id number associated with it. For example, "White" has an id of 1. You can use either the name of the color, or the id number of the color when using the code.

[edit] Using Numbers

Open up a new place with a part.

In the Command Line, type in this bit here and hit enter:

game.Workspace.Part.BrickColor = BrickColor.new(1)

The brick will turn a bright white. What you just did was tell Lua to change the Part's BrickColor to 1, or White. You set Part.BrickColor to a new color by using the BrickColor.new constructor. You constructed a new Brickcolor from the color code for White, 1.

Property you're changing Set To Value you want to set it to
game.Workspace.Part.BrickColor = BrickColor.new(1)
The color of "Part" Set to This value

[edit] Using Names

Just like before, open up a new place with a part.

In the Command Line, type in this bit here and hit enter:

game.Workspace.Part.BrickColor = BrickColor.new("White")

Instead of telling Lua that you want the brick to be the value of White, or 1, you tell it specifically that you want the brick to be "White". In this case, you used a String instead of a Number.

For a subset of common colors, an alternate notation can be used:

game.Workspace.Part.BrickColor = BrickColor.White()

[edit] Using Color3 Values

Color3s contain 3 numbers, representing the red, green, and blue component of the color.

Just like before, open up a new place with a part.

In the Command Line, type in this bit here and hit enter:

game.Workspace.Part.BrickColor = BrickColor.new(Color3.new(1, 1, 1))

This sets the R, G, and B components of the color to full brightness, creating white. Same thing as the above two examples, just a different way to get there.

[edit] Color codes

There are actually a great many color codes, not just the 64 colors available in the Color Picker window. The list is available here.

[edit] Comparing BrickColors

When comparing BrickColors to other values, you must take care to make sure that values that you're comparing are of the same type, as comparisons between values of different types in Lua *always* returns false (for details, see the note here). To get around this, the property of the BrickColor that is the same type as the other value can be compared instead. See the table below for examples.

Value Type Example
BrickColor brickColor == redPart.BrickColor
String brickColor.Name == "Really red"
Number brickColor.Number == 1004
Color3 brickColor.Color == Color3.new(1, 0, 0)

[edit] Constructors

Function Description
BrickColor.new(val) Returns a BrickColor (from val of a Number, String, Color3)
BrickColor.new(r, g, b) Returns a BrickColor from Color3 of r,g,b
BrickColor.palette(val) Returns a BrickColor (from val of a Number (0-63))
BrickColor.Random() Returns a random BrickColor
BrickColor.White() Returns White (1)
BrickColor.Gray() Returns Medium stone grey (194)
BrickColor.DarkGray() Returns Dark stone grey (199)
BrickColor.Black() Returns Black (26)
BrickColor.Red() Returns Bright red (21)
BrickColor.Yellow() Returns Bright yellow (24)
BrickColor.Green() Returns Dark green (28)
BrickColor.Blue() Returns Bright blue (23)

These properties are read-only (meaning you can't set BrickColor.r = 5) but you can use them for other things.

Property Type Description
BrickColor.Number Number The unique number that identifies the BrickColor
BrickColor.Name String the name associated with the BrickColor
BrickColor.Color Color3 the Color3 associated with the BrickColor
BrickColor.r Number the red component (between 0 and 1)
BrickColor.g Number the green component (between 0 and 1)
BrickColor.b Number the blue component (between 0 and 1)

[edit] See Also