Why is this returning false when both values are equal?

I have two colours. Both are type Color3 and they are the same colour.
This script apparently says they aren’t.

if Instance.Color==C3 then
    Instance.Color=Color3.new(1,1,1)
end
1 Like

What is the instance that you are trying to compare?

I am trying to compare a MeshPart to a Color3Value instance

Try Color3.fromRGB instead, see if that works.

Tried it. Didn’t work.
image
image

Print both Instance.Color and C3 before the if statement. Then show me the output.

Output gets converted to clamped colour

It is the same though. I will show you

Wait is C3 the color value object or the actual value of the object?

C3 is a Color3Value object in my script however in the example script, I’ve replaced it to a Color3 value

Also I have just printed everything to the output.
Color is the same in output

0.929412, 0.0156863, 0 | 0.929412, 0.0156863, 0
image

That’s strange, could I see the rest of your script?

for _,i in workspace.Parts:GetChildren()do
	if i.Border.Color==i.Color then
		i.Border.Color=Color3.new(1.0, 1.0, 1.0)
	end
	i.BrickColor=BrickColor.Red()
end

For your initial question, try setting C3 as the color value object and then use:

if Instance.Color==C3.Value then
Instance.Color=Color3.new(1,1,1)
end

yep, tried that as well. Didn’t work.

Hey man, what exactly are you trying to do here? Change the color for a limited amount of time and then change it back? Or… what? We need a bit more detail.

Making a strategy game. When you select a country, the colour of your country will change locally to white. The colour of the cities will change to red.

Okay. Really quickly, are you using a LocalScript or GlobalScript for this? (LocalScripts only change what happens with the client. GlobalScripts changes it for everyone.)

I am using a LocalScript for this

Okay, next… are they supposed to click a specific part? Or a button?

Is your script erroring? Because your first line should be:

for _,i in pairs(workspace.Parts:GetChildren()) do

When you click the flag of a country, it is meant to locally alter the colour of the country of your choice to white. The colour of the cities will change to red. It only works for some countries, not others. Very odd since the colour matches yet the if-statement doesn’t run