no-color3-constructor
Bans most new Color3(...) calls and prefers Color3.fromRGB(...).
Rule details Problem
Section titled “Rule details ”ProblemThis rule allows only these constructor forms:
new Color3()new Color3(0, 0, 0)
Everything else is reported.
When every argument is a numeric literal, the rule can fix the call by converting values to the RGB range. Numbers less
than or equal to 1 are multiplied by 255 and rounded. Numbers greater than 1 are used as-is.
That means these are all reported:
new Color3(1, 0, 0)new Color3(255, 0, 0)new Color3(0.5)new Color3(value)
Calls with one or two arguments use the useFromRGB message. Calls with three or more arguments use onlyZeroArgs.
Examples
Section titled “Examples” Incorrect
const red = new Color3(1, 0, 0);const accent = new Color3(255, 128, 64);const dynamic = new Color3(value); Correct
const red = Color3.fromRGB(255, 0, 0);const accent = Color3.fromRGB(255, 128, 64);const black = new Color3();const explicitBlack = new Color3(0, 0, 0);Conversion examples
Section titled “Conversion examples”| Input | Fixed output |
|---|---|
new Color3(0.5) | Color3.fromRGB(128, 0, 0) |
new Color3(1, 0) | Color3.fromRGB(255, 0, 0) |
new Color3(1, 1, 1) | Color3.fromRGB(255, 255, 255) |
new Color3(255, 128, 64) | Color3.fromRGB(255, 128, 64) |
Related rules
Section titled “Related rules” prefer-udim2-shorthand Cleans up another Roblox constructor pattern
prefer-sequence-overloads Checks other Roblox datatype construction patterns