Doesn’t mean it will work everywhere, especially transacting against an engine-supplied quantity such as transform.position, which might not even be stored in any format resembling what you expect it to be.
Set yourself up for success… use Vector2.Distance() and be done with it. That has the side benefit of ignoring the z component, as Vector2 is only x / y.
Floating (float) point imprecision:
Never test floating point (float) quantities for equality / inequality. Here’s why:
https://starmanta.gitbooks.io/unitytipsredux/content/floating-point.html
https://discussions.unity.com/t/851400/4
https://discussions.unity.com/t/843503/4
“Think of [floating point] as JPEG of numbers.” - orionsyndrome on the Unity3D Forums
It also sounds like you haven’t even started debugging. It could be that absolutely none of this code is even running at all for some other random reason, in which case every single thing you have investigated so far would be pointless!
Get started debugging, you’ll soon find and fix the problem.