If you want something to happen when the player gets within a certain distance from an object attach an area to the player and connect the body_enter-signal. That way you don’t need to check the distance every frame. The physics engine is much better at checking distances than such a check in a script.