Help with changing the part's color!

So I am making a part that has a color value and when the iteration of the for loop finishes it adds 10 to each value in the fromRGB() parentheses (or color code, don’t know what it is called). If i run the script it freezes my studio for 10 seconds and then nothing happens, the color does not change. Here is the script:

local ColorLooping = script.Parent
local ColorLoopingPartColor = Color3.fromRGB(100, 100, 100)

for start = 1, 10, 1 do
	ColorLoopingPartColor = ColorLoopingPartColor + Color3.fromRGB(10, 10, 10)
	wait(1)
end
1 Like

Try this code!

local ColorLooping = script.Parent
local ColorLoopingPartColor = Color3.fromRGB(100, 100, 100)
local ColorLoopingPartColorAdd = Color3.fromRGB(10,10,10)
for start = 1, 10 do 
    local R,G,B = ColorLoopingPartColor.R, ColorLoopingPartColor.G, ColorLoopingPartColor.B
	local A,B,C = ColorLoopingPartColorAdd.R, ColorLoopingPartColorAdd.G, ColorLoopingPartColorAdd.B
	ColorLoopingPartColor = Color3.fromRGB(R+A,G+B,B+C)
	wait(1)
end
1 Like

Ye, I don’t think it’s working the actual part just turned into a gray block.
image

1 Like

I think i fixed it (its different)

local ColorLooping = script.Parent
local ColorLoopingPartColor = Color3.fromRGB(100, 100, 100)
local ColorLoopingPartColorAdd = Color3.fromRGB(10,10,10)
for start = 1, 10 do 
    local R,G,B = ColorLoopingPartColor.R, ColorLoopingPartColor.G, ColorLoopingPartColor.B
	local A,B,C = ColorLoopingPartColorAdd.R, ColorLoopingPartColorAdd.G, ColorLoopingPartColorAdd.B
	ColorLoopingPartColor = Color3.new(R+A,G+B,B+C)
	wait(1)
end

Nope, it’s still grey. Oh, you FORGOT to add an increment value, let me see if that works.
edit: Nope, still the same thing.

Are you setting the part’s color atleast? If my script wouldn’t work, it would be black or white or any other color. Because it looks like the default color for a part

1 Like

I did set the part’s color to (100, 100, 100) in the properties. Still the same thing.

1 Like
local ColorLooping = script.Parent
local ColorLoopingPartColor = Color3.fromRGB(100, 100, 100)
local ColorLoopingPartColorAdd = Color3.fromRGB(10,10,10)
for start = 1, 10 do 
    local R,G,B = ColorLoopingPartColor.R, ColorLoopingPartColor.G, ColorLoopingPartColor.B
	local A,B,C = ColorLoopingPartColorAdd.R, ColorLoopingPartColorAdd.G, ColorLoopingPartColorAdd.B
	ColorLoopingPartColor = Color3.new(R+A,G+B,B+C)
    ColorLooping.Color = ColorLoopingPartColor
	wait(1)
end

You need to add ColorLooping.Color.

Now it works! So I guess in your script your just assigning each number in the fromRGB() to a variable and then update the variable to show the new color?

Yes. Because you can’t add Color3 Variable to Color3 Variable

Oh, that makes sense. I never knew you could do that. In some youtube tutorials they show you this:

local Number = 1
local Sum = Number + 1
print(Sum)

This is incorrect right? You can’t add a variable to the same variable.

You can add to the same variable.
You cant do Color3 + Color3.
You should use part.Color to set the color of the part

Oh, so what if I want to double the variable value, I can’t just do this right?

local Number = 10
Local DoubleTheNumber = Number + Number
Print(DoubleTheNumber)

You can do this. The only thing that you did wrong was increasing an color with another color and you didn’t set the color of the part.

Oh ok. Thanks for clarifying some thing for me and helping with the script!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.