Scripting Helpers is winding down operations and is now read-only. More info→
Log in to vote

Adding/Subtracting Color3s? [Re-Edited]

Asked by 10 years ago
Edited by JesseSong 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

Is there a way to add/subtract Color3 values to BackgroundColor3 values in GUI items?


local Pixels = Leg1:GetChildren() for i = 1, #Pixels do Pixels[i].BackgroundColor3 =,256,256) + Pixels[i].BackgroundColor3 end

Error Code:

14:01:06.842 - Plugin_144415441.SkinModelPlugin:122: attempt to perform arithmetic on a userdata value

Please be more specific.What do you mean? Perhaps give an example of what you're trying to accomplish? AmericanStripes 610 — 10y
Added FromLegoUniverse 264 — 10y
Ah. Thank you. AmericanStripes 610 — 10y
When paraphrasing lua code, make sure you encode your code in a code block. [I know this question is 6 years old as of November 7 2020, I just edited the question because the poster didn't use a code block properly] JesseSong 3916 — 3y

1 answer

Log in to vote
Answered by 10 years ago

To do this, we need to first understand what Color3 is.

Wiki Definition: A real-valued RGB color tuple, with elements ranging from [0,1]. The Color3 data type is often used in setting the colors of objects that aren't related to bricks, such as GUIs, Sparkles, etc.

RGB (Red, Green, Blue) are the 3 main colors in ROBLOX. Messing with the Red, Green, and Blue values, is what gives you colors such as Pink, Yellow, Etc...

Knowing that, we can move on to how setting a Color3 works;

script.Parent.BackgroundColor3 =, Green, Blue)

Knowing that Color3's are setup like that, we can now try to subtract each value:

game.StarterGui.ScreenGui.Frame.BackgroundColor3 = - 1)/255, (game.StarterGui.ScreenGui.Frame.BackgroundColor3.g - 1)/255, (game.StarterGui.ScreenGui.Frame.BackgroundColor3.b - 1)/255)


Works, thanks FromLegoUniverse 264 — 10y

Answer this question