Why is this returning false when both values are equal?

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

Yep, they are colours. >> chars

could you show your code? you were making a lot of syntax issues earlier

Syntax issues? Like what? >>chars

Edit: my code is above.

I ignore everything when creating temporarily lines of code. I create them with only functionality in mind

I meant the code where you use FuzzyEq
that code you referenced just now is from before that

attempt to index boolean with 'R'

Input: areColorsEqual(raycastResult.Instance.Color==workspace.CountryData[countryName].C3.Value)

My bad, just caught it. Too many lines so I’m just skimming them now

I didn’t send that code. >>chars

Tried it now, it detects more provinces but some are still left unchanged.

Why are you inputting an argument with w comparison operation in the middle of it? That is of course going to output a boolean.

1 Like

My bad, just caught it. Too many lines so I’m just skimming them now