Try:
func _physics_process(delta):
var obj = getparent().getnode("Player")
if obj:
var dir = (obj.globalposition - globalposition).normalized()
moveandcollide(dir * speed * delta)
If that works it's because your Player node wasn't _ready()
at the time that object was _ready()
.
"When instantiating a scene connected to the first executed scene, Godot will instantiate nodes down the tree (making init calls) and build the tree going downwards from the root. This causes _entertree calls to cascade down the tree. Once the tree is complete, leaf nodes call _ready. A node will call this method once all child nodes have finished calling theirs. This then causes a reverse cascade going up back to the tree's root."