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

[Color3] Why does this not add a math value?

Asked by 9 years ago

The color3 parent Im trying to change is a Frame, Im getting this error.

4: attempt to perform arithmetic on field 'BackgroundColor3' (a userdata value)

spawn(function()
    while wait() do
        for i = 0,1,.1 do
            script.Parent.BackgroundColor3 = script.Parent.BackgroundColor3 + Color3.new(1/255,1/255,1/255)
            wait()
        end
    end
end)
0
Try adding a vector3 value. EzraNehemiah_TF2 3552 — 9y
0
You can't add colors, subtract, multiply or divide colors. aquathorn321 858 — 9y

1 answer

Log in to vote
2
Answered by
Redbullusa 1580 Moderation Voter
9 years ago

Try this script. All I did was add the intended unit to each element in the Color3 value while referring to this.

local sp = script.Parent
for i = 0,1,.1 do
    sp.BackgroundColor3 = Color3.new(sp.BackgroundColor3.R + (1/255), sp.BackgroundColor3.G + (1/255), sp.BackgroundColor3.B + (1/255))
    wait()
end

Line 3:

sp.BackgroundColor3 = Color3.new
    (
    sp.BackgroundColor3.R + (1/255),
    sp.BackgroundColor3.G + (1/255),
    sp.BackgroundColor3.B + (1/255)
    )
Ad

Answer this question