Invalid access to property or key on a base object of type 'null instance' in Godot 4

By Eduardo Orellana · Updated

The node you reached for was not found. In Godot 4 a $Player or get_node_or_null("Player") that finds no node gives you a reference to nothing, and reading .position from it fails with this error. Fix the node path, or the scene, so the node exists where the path says.

What Godot is checking

GDScript compiles player.position to a named property read, and the virtual machine asks the value in player for position. Here player holds an Object reference that points at no object, so there is nothing to ask, and the function stops with this error.

'null instance' is how Godot names that case: the variable's type is Object, but no object is behind it. That is what $Player and get_node() return when no node sits at that path, after printing their own Node not found error, and what get_node_or_null() returns without printing anything.

A variable that was never assigned at all reads as 'Nil' instead, and an object that existed and was freed reads as 'previously freed'. Both have their own pages, linked below.

Read the first error in the output, not the last: Node not found names the path that failed and the node it was relative to.

Reproduce it

An @onready variable filled from $Player, in a scene that has no child named Player. The scene is one Node with this script.

extends Node

@onready var player: Node2D = $Player

func _ready() -> void:
	print(player.position)
	print("after")

What Godot 4.7.2 prints

Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

ERROR: Node not found: "Player" (relative to "/root/Repro").
   at: get_node (scene/main/node.cpp:1975)
   GDScript backtrace (most recent call first):
       [0] @implicit_ready (res://answers/invalid-access-to-property-or-key-on-null-instance/repro.gd:3)
SCRIPT ERROR: Invalid access to property or key 'position' on a base object of type 'null instance'.
   at: _ready (res://answers/invalid-access-to-property-or-key-on-null-instance/repro.gd:6)
   GDScript backtrace (most recent call first):
       [0] _ready (res://answers/invalid-access-to-property-or-key-on-null-instance/repro.gd:6)

Fix it

The same script in a scene that has a Node2D child named Player, so $Player finds it. If the node lives elsewhere, the path must say where: $"../Player" for a sibling, or %Player for a node marked Access as Unique Name in its scene.

extends Node

@onready var player: Node2D = $Player

func _ready() -> void:
	print(player.position)
	print("after")

What the fixed script prints

Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org

(64.0, 32.0)
after

The node was renamed or moved

$Player is a path relative to the node the script is on. Renaming the child, or moving it under another parent, breaks the path without any warning in the script editor. The Node not found line in the output names the path and the node it started from.

The path is read before the node is in the tree

A $Path in a plain variable declaration, without @onready, runs when the script instance is created, before the node's children are ready. @onready waits for _ready, which is why the scripts on this page use it.

The same error in earlier Godot versions

Godot 4.0 to 4.2, and Godot 3, printed it as: Invalid get index 'position' (on base: 'null instance'). The cause and the fix are the same.

Verified on Godot 4.7.2

Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 6 October 2026, and the output above is what Godot printed, unedited.

Where the check lives in Godot's source: [gdscript_vm.cpp line 1281, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_vm.cpp#L1281), [gdscript_vm.cpp lines 62 to 72, where 'null instance' is named](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_vm.cpp#L62-L72).

Questions

What is the difference between 'null instance' and 'Nil'?
'Nil' means the variable holds nothing at all. 'null instance' means it holds an Object reference with no object behind it, which is what a failed node lookup returns.
Why did this error used to say Invalid get index?
Godot 4.3 reworded it. Godot 4.0 to 4.2 and Godot 3 printed Invalid get index 'position' (on base: 'null instance'). for the same check.