Pulse Works Studio

Invalid access to property or key 'position' on a base object of type 'Nil'.

The script read a property from null. position is fine; the object is not there.

Cause

Named property access on a Nil variant produces this runtime error. It shows up when a child path is wrong, when a packed scene failed to instantiate, or when a reference was used after queue_free(). Check the reference before reading position, velocity, or any other property.

Fix

func knock_from(source: Node2D) -> void:
	if source == null:
		return
	var away := global_position - source.global_position
	velocity = away.normalized() * 240.0

Related

Godot Dev Tools is a Pulse Works Studio project. All error explainers.