Data type
Color3
A color value comprised of red, green, and blue components.
About 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 4
Color3.new
(red: number = 0, green: number = 0, blue: number = 0)Returns aColor3with the given red, green, and blue values.Color3.fromRGB
(red: number = 0, green: number = 0, blue: number = 0)Returns aColor3from given components within the range of 0 to 255.Color3.fromHSV
(hue: number, saturation: number, value: number)Returns aColor3from the given hue, saturation, and value components.Color3.fromHex
(hex: string)Returns aColor3from a given hex value.
Properties 3
R
: numberThe red value of the color.G
: numberThe green value of the color.B
: numberThe blue value of the color.
Methods 3
Lerp
(color: Color3, alpha: number) → Color3Returns aColor3interpolated between two colors.Returns a
Color3interpolated between two colors. Thealphavalue 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.15ToHSV
() → number, number, numberReturns the hue, saturation, and value of aColor3.Returns the hue, saturation, and value of a
Color3. This function is the inverse operation of theColor3.fromHSVconstructor.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 1ToHex
() → stringReturns the hex code of aColor3.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.fromHexto 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
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.