I'm gonna guess it was a caching problem since sometimes getPosition() returned null as well(as in while doing the floor the object got de-cached, and when requesting the old gameobject it didn't exist anymore).
I fixed it thanks to @Aidden by storing the location instead of the gameobject when...