Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.
Color3
The Color3 data type describes a color using red, green, and blue components in the range of 0 to 1. Unlike the BrickColor data type which describes named colors, Color3 is used for precise coloring of objects on screen through properties like BasePart.Color and GuiObject.BackgroundColor3.
Constructors
| Name | Type / Returns | Description |
|---|---|---|
| Color3.new | Returns a Color3 with the given red, green, and blue values. | |
| Color3.fromRGB | Returns a Color3 from given components within the range of 0 to 255. | |
| Color3.fromHSV | Returns a Color3 from the given hue, saturation, and value components. | |
| Color3.fromHex | Returns a Color3 from a given hex value. |
Color3.new
Returns a Color3 with the given red, green, and blue values. The parameters should be within the range of 0 to 1.
local red = Color3.new(1, 0, 0)
local green = Color3.new(0, 1, 0)
local blue = Color3.new(0, 0, 1) Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| red | number | 0 | The red component of the color, from 0 to 1. |
| green | number | 0 | The green component of the color, from 0 to 1. |
| blue | number | 0 | The blue component of the color, from 0 to 1. |
Color3.fromRGB
Creates a Color3 with the given red, green, and blue components. Unlike most other Color3 functions, the parameters for this function should be within the range of 0 to 255.
local red = Color3.fromRGB(255, 0, 0)
local green = Color3.fromRGB(0, 255, 0)
local blue = Color3.fromRGB(0, 0, 255) Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| red | number | 0 | The red component of the color, from 0 to 255. |
| green | number | 0 | The green component of the color, from 0 to 255. |
| blue | number | 0 | The blue component of the color, from 0 to 255. |
Color3.fromHSV
Creates a Color3 with the given hue, saturation, and value. The parameters should be within the range of 0 to 1.
local red = Color3.fromHSV(1, 1, 1)
local green = Color3.fromHSV(0.3333333, 1, 1)
local white = Color3.fromHSV(0, 0, 1) Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| hue | number | The hue of the color, from 0 to 1. | |
| saturation | number | The saturation of the color, from 0 to 1. | |
| value | number | The value (brightness) of the color, from 0 to 1. |
Color3.fromHex
Returns a new Color3 from a six- or three-character hexadecimal format, case insensitive. A preceding hashtag (#) is ignored, if present. This function interprets the given string as a typical web hex color in the format RRGGBB or RGB (shorthand for RRGGBB). For example, #FFAA00 produces an orange color and is the same as #FA0.
local red = Color3.fromHex("FF0000")
local magenta = Color3.fromHex("ec008c")
local black = Color3.fromHex("000")
local white = Color3.fromHex("#FFF") Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| hex | string | A three- or six-character hexadecimal color string, optionally prefixed with #. |
Properties
| Name | Type / Returns | Description |
|---|---|---|
| Color3.R | number | The red value of the color. |
| Color3.G | number | The green value of the color. |
| Color3.B | number | The blue value of the color. |
Color3.R
The red value of the color.
| Field | Value |
|---|---|
| type | number |
Color3.G
The green value of the color.
| Field | Value |
|---|---|
| type | number |
Color3.B
The blue value of the color.
| Field | Value |
|---|---|
| type | number |
Methods
| Name | Type / Returns | Description |
|---|---|---|
| Color3:Lerp | Color3 | Returns a Color3 interpolated between two colors. |
| Color3:ToHSV | number, number, number | Returns the hue, saturation, and value of a Color3. |
| Color3:ToHex | string | Returns the hex code of a Color3. |
Color3:Lerp
Returns a Color3 interpolated between two colors. The alpha value should be within the range of 0 to 1.
local white = Color3.new(1, 1, 1)
local black = Color3.new(0, 0, 0)
local gray10 = white:Lerp(black, 0.1)
print(gray10) --> 0.9, 0.9, 0.9
local gray50 = white:Lerp(black, 0.5)
print(gray50) --> 0.5, 0.5, 0.5
local gray85 = white:Lerp(black, 0.85)
print(gray85) --> 0.15, 0.15, 0.15 Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| color | Color3 | The color to interpolate toward. | |
| alpha | number | An interpolation value between 0 and 1, where 0 returns this color and 1 returns the target color. |
Returns
| Type | Description |
|---|---|
| Color3 |
Color3:ToHSV
Returns the hue, saturation, and value of a Color3. This function is the inverse operation of the Color3.fromHSV() constructor.
local red = Color3.fromRGB(255, 0, 0)
local green = Color3.fromRGB(0, 255, 0)
local redH, redS, redV = red:ToHSV()
print(redH, redS, redV) --> 1 1 1
local greenH, greenS, greenV = green:ToHSV()
print(greenH, greenS, greenV) --> 0.3333333 1 1 Returns
| Type | Description |
|---|---|
| number | |
| number | |
| number |
Color3:ToHex
Converts the color to a six-character hexadecimal string representing the color in the format RRGGBB. It is not prefixed with an octothorpe (#).
The returned string can be provided to Color3.fromHex() to produce the original color.
local red = Color3.fromRGB(255, 0, 0)
local magenta = Color3.fromRGB(236, 0, 140)
local redHex = red:ToHex()
print(redHex) --> ff0000
local magentaHex = magenta:ToHex()
print(magentaHex) --> ec008c Returns
| Type | Description |
|---|---|
| string |
Functions
| Name | Type / Returns | Description |
|---|---|---|
| Color3.toHSV | number, number, number | Returns the hue, saturation, and value of a Color3. |
Color3.toHSV
Deprecated. This function is functionally equivalent to Color3:ToHSV().
Returns the hue, saturation, and value of a Color3. This function is the inverse operation of the Color3.fromHSV() constructor.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| color | Color3 | The Color3 to convert to HSV. |
Returns
| Type | Description |
|---|---|
| number | |
| number | |
| number |