BrickColor

< Global namespace | ROBLOX namespace

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.

Quick Reference[edit]

Constructors
SyntaxDescription
BrickColor.Black()Returns Black (26)
BrickColor.Blue()Returns Bright blue (23)
BrickColor.DarkGray()Returns Dark stone grey (199)
BrickColor.Gray()Returns Medium stone grey (194)
BrickColor.Green()Returns Dark green (28)
BrickColor.new(string val)Constructs a BrickColor from it's name.
BrickColor.new(number r, number g, number b)Constructs the closest BrickColor that can be matched to the specified RGB components.
BrickColor.new(int val)Constructs a BrickColor from it's numerical index.
BrickColor.new(Color3 color)Constructs the closest BrickColor that can be matched to the specified Color3.
BrickColor.palette(int paletteValue)Constructs a BrickColor from its palette index.

This must be an integer between 0 and 127.

BrickColor.random()Returns a random BrickColor
BrickColor.Red()Returns Bright red (21)
BrickColor.White()Returns White (1)
BrickColor.Yellow()Returns Bright yellow (24)
Properties
SyntaxDescription
number b The blue component of the BrickColor's Color3 value (between 0 and 1)
Color3 Color The Color3 associated with the BrickColor.
number g The green component of the BrickColor's Color3 value (between 0 and 1)
string Name The name associated with the BrickColor.
int Number The unique number that identifies the BrickColor.
number r The red component of the BrickColor's Color3 value (between 0 and 1)

Constructors[edit]

BrickColor.new[edit]

BrickColor BrickColor.new(string val)

Description:
Constructs a BrickColor from it's name.

BrickColor BrickColor.new(int val)

Description:
Constructs a BrickColor from it's numerical index.

BrickColor BrickColor.new(number r, number g, number b)

Description:
Constructs the closest BrickColor that can be matched to the specified RGB components.


Notes:

  • All of the parameters should be numbers between 0 and 1.

BrickColor BrickColor.new(Color3 color)

Description:
Constructs the closest BrickColor that can be matched to the specified Color3.

BrickColor.palette[edit]

BrickColor BrickColor.palette(int paletteValue)

Description:
Constructs a BrickColor from its palette index. This must be an integer between 0 and 127.

BrickColor.random[edit]

BrickColor BrickColor.random()

Description:
Returns a random BrickColor

Basic Color Constructors[edit]

BrickColor BrickColor.White()

Description:
Returns White (1)

BrickColor BrickColor.Gray()

Description:
Returns Medium stone grey (194)

BrickColor BrickColor.DarkGray()

Description:
Returns Dark stone grey (199)

BrickColor BrickColor.Black()

Description:
Returns Black (26)

BrickColor BrickColor.Red()

Description:
Returns Bright red (21)

BrickColor BrickColor.Yellow()

Description:
Returns Bright yellow (24)

BrickColor BrickColor.Green()

Description:
Returns Dark green (28)

BrickColor BrickColor.Blue()

Description:
Returns Bright blue (23)

Properties[edit]

All of these properties are read-only. You cannot assign them.

BrickColor.Number[edit]

int BrickColor.Number [readonly]

Description:
The unique number that identifies the BrickColor.

BrickColor.Name[edit]

string BrickColor.Name [readonly]

Description:
The name associated with the BrickColor.

BrickColor.Color[edit]

Color3 BrickColor.Color [readonly]

Description:
The Color3 associated with the BrickColor.

BrickColor.r[edit]

number BrickColor.r [readonly]

Description:
The red component of the BrickColor's Color3 value (between 0 and 1)

BrickColor.g[edit]

number BrickColor.g [readonly]

Description:
The green component of the BrickColor's Color3 value (between 0 and 1)

BrickColor.b[edit]

number BrickColor.b [readonly]

Description:
The blue component of the BrickColor's Color3 value (between 0 and 1)

Using BrickColor codes[edit]

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.

Using Numbers[edit]

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

Using Names[edit]

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()

Using Color3 Values[edit]

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.

Color codes[edit]

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

Comparing BrickColors[edit]

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)

See Also[edit]

Referenced by