Why is this returning false when both values are equal?

print(…, (instance.Color == C3))
Don’t know why I put an if.

Anyways I think you should check out what Azarctic said, they’re probably right.

I tried comparing by BrickColor as well which afaik would get past that problem. It didn’t work.

Tried the script, getting [false] printed. Very odd

The brickcolor comparison not working is beyond my knowledge. Should probably check out what Azarctic said, and if that doesn’t work reinstall studio. And if that doesn’t work, just retype the script. I’ve had a similar issue once for the longest time where I was unable to find the issue, so I retyped the script and it worked flawlessly.

yes, but you can also check if they’re “close enough”

Tried running the game through the RobloxPlayer as well. Same results, didn’t work.

Edit: rewrote the script like 6 or 7 times

print(
	raycastResult.Instance.Color==workspace.CountryData[countryName].C3.Value.."\n"..
	tostring(region.Color).."\n"..
	tostring(workspace.CountryData[countryName].C3.Value)
)

Now getting 'attempt to concatenate Color3 with string' when I tried the exact same thing earlier with no issue printing

wait so is there only one color value?

What do you mean one? >> char limit

Is there only one Color3Value that your using?

Currently, yes. >> char limit charss

So your using a color3value that remains the same color and comparing it to different colors? Or am i missing something?

Yes that’s it. >> chars char limit

here’s an example of comparing 2 values like Vector3s

local Part = Instance.new("Part")
print( "Part color is: [" .. tostring(Part.Color) .. "]" )


local MyColor = Color3.new(0.639216, 0.635294, 0.647059)
print( "MyColor is: [" .. tostring(MyColor) .. "]" )
print( "Do they equal? " .. tostring(MyColor == Part.Color) )


function fuzzyEq(color0, color1, epsilon)
	return
		math.abs(color0.r - color1.r) < epsilon and
		math.abs(color0.g - color1.g) < epsilon and
		math.abs(color0.b - color1.b) < epsilon
end
print( "Do they close enough? " .. tostring(fuzzyEq(Part.Color, MyColor, 0.005)) )

The Output:
image

you need to use FuzzyEq because floats (decimal numbers) can be off by a tiny tiny bit Floating-point arithmetic - Wikipedia

Vector3s have FuzzyEq built in, but you need to make it yourself with Color3

1 Like

Isn’t that that your problem then? it only sometimes works because the other times your just comparing different colors no?

local function areColorsEqual(colorA, colorB, epsilon)
	local epsilon = epsilon or 0.001
	
	if math.abs(colorA.R - colorB.R) > epsilon then
		return false
	end
	
	if math.abs(colorA.G - colorB.G) > epsilon then
		return false
	end
	
	if math.abs(colorA.B - colorB.B) > epsilon then
		return false
	end
	
	return true
end

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

in this case, you’re just having an issue because you’re doing
something0 == something1 .. someString

it does the concatenation first, so you need parenthesis
(something0 == something1) .. someString

–Get the province of the city
–Check if the province has the same colour as the players country
–If yes, set the province colour to white.

attempt to index boolean with 'r' Line11

make sure the values you input into the function are colors

Wrong line, concatenation error is on the last line