Roblox Wiki
Advertisement
Roblox Wiki
Tutorial page
This article is an easy tutorial.

This tutorial goes over the usage of the Color3 data type. There are three ways to do it.

That being said, keep in mind that this is just an explanation of how the formats work. You aren't supposed to calculate the values; Roblox Studio has a color picker that lets you pick the color by dragging it around. It's just that knowing what the numbers mean will help you manipulate the colors with greater precision.

RGB[]

All colors you can think of come from three primary colors: red, green, and blue. Different amounts of each primary color mix together to form a new color. You may have heard that the primary colors are red, yellow, and blue, but this applies only if you're mixing paints. When mixing light, and when you're working with Roblox Studio, the colors are red, green and blue.

RGB is an additive color model. The colors red, green, and blue mix together to form a composite color. RGB uses three values, one for each color. The first value tells you how much red is in the color, the second value tells you how much green is in the color, and the third tells you how much blue is in the color.

All numbers are between 0 and 1. (1,0,0) would make red, (0,1,0) would make green, and (0,0,1) would make blue. You can mix the colors using the three numbers. (1,0,1) is red and blue put together, which is purple. (1,1,0) is red and green, which is yellow. Lastly, (0,1,1) is green and blue, which is aqua. Remember, we're not mixing paint here, we're mixing light. The color combinations are different than the ones you would learn if you're drawing or painting.

The number can also be a decimal. For example, (1, 0.5, 0) is red and some green mixed in. So, while (1,1,0) makes yellow, (1,0.5,0) makes orange because orange has less green than yellow.

If all values are the same, the color will make some shade of grey, again, with higher numbers making lighter shades. So, (0.1,0.1,0.1) would make a dark grey while (0.9,0.9,0.9) would make a lighter grey.

To make a script that changes the color of a part, simply enter the following code. Note that the script MUST be the child of the part.

script.Parent.Color3 = Color3.new(x,y,z) --Replace x, y, and z with the number values.

.fromRGB[]

Another way to enter RGB values is by entering "fromRGB" instead of "new." Only this time, the values will range from 0 to 255, with (0,0,0) being black and (255, 255, 255) being white. This way, you don't have to work with as many decimals, but the numbers will be larger, likely in the double or triple digits. This is the way developers outside Roblox use RGB, and also the one used in most color pickers online. The code is below.

script.Parent.Color3 = Color3.fromRGB(x,y,z)

.fromHSV[]

HSV is an alternative to RGB. Instead of using red, green and blue values, HSV stands for hue, saturation and value. These are all very new terms, so I will explain them here.

Hue[]

ColorWheel

The hue in the color wheel

Hue is the actual color used. We will use this color wheel to right. You can see that it takes a full circle, starting at red, or 0°. The arrow moves in a counterclockwise direction, ending back at red, or 360°. Normally, to find the color value, you would find the counterclockwise angle between 0° and the color on the wheel.

So, red is at 0°. Aqua is halfway around the circle, so it's at 180°. Indigo is about 1/3 of the way around the circle, so its angle is about 120°. Lime green, 2/3 around the circle, is at about 240°.

However, instead of using numbers from 0 to 360°, the Roblox system only takes values from 0 to 1. So, you would give a decimal/fraction of the whole circle.

So, red is at 0, aqua is at 0.5, Indigo is at 1/3, and lime green is at 2/3.

Saturation[]

Saturation, also known as chroma, refers to how much color is in the shade. So, 1 would give the colors in the wheel, while 0 would make a black-and-white color.

Value[]

Value, also known as lightness, refers to how much light is in the color. A lightness value of 0 would black, regardless of what the other values are, because black is the complete absence of light. 1 would make white regardless of what the other values are because white is a combination of all the possible wavelengths of light.

To script an HSV color, type the following into your script. The x is for hue, y is for saturation, and z is for value.

script.Parent.Color = Color3.fromHSV(x,y,z)
Advertisement