I'm trying to change the color of a GUI while subtracting.
The current "BackgroundColor3" is (255, 255, 255)
I'm trying to minus 1, 255 times from the background color to change the color 3 black. I already tried
This assume that "Gui" is already defined
for i = 1, 255 do wait(0) Gui.BackgroundColor3 = Gui.BackgroundColor3 - Color3.new(1, 1, 1)
It doesn't work.
Do I use colorsequence or someething?
I don't understand.
Color3 is not Vector3; it is not a math object. So you can't do math with it, and hopefully you do not have to . . .
Here, since you simply go from white to black, you should make use of the "i" in the loop.
for i = 255,0,-1 do wait() Gui.BackgroundColor3 = Color3.fromRGB(i,i,i) end
However in more complex situations you are almost always need to use lerp. It would look like this.
--(these variables can be anything) local original = Color3.new(1,1,1) local goal = Color3.new(0,0,0) local inc = 1/100 for i=0,1,inc do wait() gui.BackgroundColor3 = original:lerp(goal,i) end
Lastly, if you really have to do actual math with the RGB values, which should be a last resort, simply take them out! i.e. Vector3.new(color.r, color.g, color.b)
Hope I helped!