BrickColor
BrickColor
A BrickColor value is a specific color value. They are used instead of Color3 values on bricks and other 3D objects.
BrickColor values are numbers that represent colors. For example, 1 is white. 45 is a light blue. There are many different colors available, see the list here. |
Using BrickColors
There are actually two ways to use BrickColor codes, the number code and the color code.
Each code has a number associated with it. For example, "White" is 1. You can use either the name of the color, or the number for the color when using the code.
Using Numbers
Open up a new place with a part. Click here for a quick guide on how to set up a script testing Place.
In the Command Line, type in this bit here and hit enter:
Template:CodeExamplegame.Workspace.Part.BrickColor = BrickColor.new(1)
The brick will turn a bright shade of white. What you just did was tell Lua to change the Part's Brick Color to 1, or White. You set Part.BrickColor to a new color by using the BrickColor.new constructor. You constructed a new Brickcolor using 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
Just like before, open up a new place with a part. Click here for a quick guide on how to set up a script testing Place.
In the Command Line, type in this bit here and hit enter: Template:CodeExamplegame.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.
Using Color3 Values
Color3s work similar to Vector3s, in that they both use 3 numbers.
Just like before, open up a new place with a part. Click here for a quick guide on how to set up a script testing Place.
In the Command Line, type in this bit here and hit enter: Template:CodeExamplegame.Workspace.Part.BrickColor = BrickColor.new(Color3.new(1, 1, 1))
This sets the R G B settings for the Color3 to full, full, full. Meaning: white! Same thing as the above two examples, just a different way to get there.
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.
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 |
BrickColor.Gray | Returns Gray |
BrickColor.DarkGray | Returns Dark Gray |
BrickColor.Black | Returns Black |
BrickColor.Red | Returns Red |
BrickColor.Yellow | Returns Yellow |
BrickColor.Green | Returns Green |
BrickColor.Blue | Returns Blue |
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) |