Skip to content

No Color3 Constructor

ErrorAuto-fixableRoblox
small-rules/no-color3-constructor

Ban new Color3(...) except new Color3() or new Color3(0, 0, 0). Use Color3.fromRGB() instead.

Diagnostic Messages

onlyZeroArgs
Use Color3.fromRGB() instead of new Color3(). new Color3() uses floats [0-1] and performs worse than Color3.fromRGB() which uses [0-255]. Only 'new Color3()' or 'new Color3(0, 0, 0)' are allowed.
useFromRGB
Use Color3.fromRGB() instead of new Color3(). new Color3() uses floats [0-1] and performs worse than Color3.fromRGB() which uses [0-255].

Configuration

This rule accepts one options object after the severity.

reportUnknownComponentsOptional

Report new Color3(...) calls when one or more components are not numeric literals.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-color3-constructor": [
"error",
{
"reportUnknownComponents": true
}
]
}
}

Examples

single-channel Color3 constructor
new Color3(255);

After auto-fix

Color3.fromRGB(255, 0, 0);
Color3 fromRGB factory
Color3.fromRGB(255, 128, 64);