Why is this returning false when both values are equal?

This game will contain more than 10,000 lines of code near the end and around 3200 cities and meshes, not to mention units, flags, countries and everything else.

I know optimization will be a big part in making sure the game is playable but first I need the mechanics down. I am optimizing while going through (which is what this update is) but I don’t want to focus too hard on it without getting the basic features down.

Too much to screenshot. 3200 cities and meshes. Several hundred folders (nearing a thousand) in just baseplate alone.

Edit: trying to send as much as possible but no way to fit that many cities/meshes in.

where is the if statement exactly? Before it gets turned red or after?

Okay thats fine. Also I don’t mean to screenshot everything in your game, I mean your script, and a small portion of the workspace which showcases the part folder.

It turns red at the last line of the if statement, after parsing through regions. Doesn’t matter though, since C3 isnt a city part. C3 does not change at all. It is static throughout the entire gameplay

for _,i in pairs(workspace.Baseplate.Cities[countryName]:GetChildren())do --get all cities belonging to country
	local region = workspace.Baseplate.Parts:FindFirstChild(i:GetAttribute("Region")) --get all provinces relating to that city
	local params = RaycastParams.new()
	params.FilterType= Enum.RaycastFilterType.Include
	params.FilterDescendantsInstances = {workspace.Baseplate.Parts}
	local raycastResult = workspace:Raycast(i.Position, Vector3.new(0, -10, 0), params) --check if city is located inside the province

	if region and raycastResult and raycastResult.Instance==region and raycastResult.Instance.Color==workspace.CountryData[countryName].C3.Value then --if the province is found, the city is inside the province and the province colour matches with the countries colour
		region.Color=Color3.new(1.0, 1.0, 1.0) --set the province colour to white
	end
	i.BrickColor=BrickColor.Red() --turn the city red
end

Commented for explanation

oh i get it
put the line that changes it red before the if statement

Change the res? What do you mean?

your checking if its red before it even turns red, (i think I’m not the brightest)

No. That part of the code is fine and unrelated.

Changing it back to red regardless if it turned white or stayed red, forcing it to remain red regardless of the if statement.

The part that is turning red and the mesh that is turning white are completely different.
The former works perfectly fine and is only used twice. Once to set it to red, another to determine the region it belongs to.

Nope. Color3 didn’t work for me

Is it a meshpart or a mesh? If it is a mesh the you have to do mesh.VertexColor = Color3

MeshPart. >> character limit char limit

restart your studio :growing_old:
charssssss

Tried that. Didn’t work. >>chars

Okay, list everything that you have tried.

Tried converting both colors to Color3 then comparing
Tried doing the same with BrickColor instead
Tried doing both except changing just one colour
Tried restarting studio
Tried scanning for all meshparts sharing the wanted colour
Tried converting both to strings and comparing those

Might be missing some

Try putting the line where it changes it red before the if statement