Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

2 comments

0

Try adding a vector3 value.

0

You can't add colors, subtract, multiply or divide colors.

1 answer

✓ Accepted answer

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)
	)

This discussion is preserved as it was. New answers, comments, and votes are closed.