The "onready" keyword was removed in Godot 4: use @onready
By Eduardo Orellana · Updated
Write @onready instead of onready. In Godot 4, onready var label = $Label is @onready var label: Label = $Label, which still waits until the node is ready before it looks the child up. The old keyword fails to parse with The "onready" keyword was removed in Godot 4.
What Godot is checking
GDScript 2.0 turned onready, export and tool into annotations. The parser recognises the old onready keyword so it can name the replacement, and stops: the script does not load.
@onready works as onready did: the variable's value is computed just before _ready runs, when the node and its children are in the scene tree, so a $Path to a child finds it. A plain var with a $Path runs earlier, when the script instance is created, before the children are added.
Reproduce it
A Godot 3 onready variable in a Godot 4 project. The scene is one Node with a Label child.
extends Node
onready var label = $Label
func _ready():
print(label.name)
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: The "onready" keyword was removed in Godot 4. Use the "@onready" annotation instead.
at: GDScript::reload (res://answers/onready-keyword-removed-in-godot-4/repro.gd:3)
ERROR: Failed to load script "res://answers/onready-keyword-removed-in-godot-4/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
The annotation, with the child's type, in the same scene.
extends Node
@onready var label: Label = $Label
func _ready() -> void:
print("found ", label.name, ", a ", label.get_class())
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
found Label, a LabelVerified 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_parser.cpp line 1201, the message](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_parser.cpp#L1201).
Questions
- Can I combine @onready with @export?
- Godot warns against it: an exported value set in the Inspector would be overwritten by the @onready one when the node becomes ready. Use one or the other for a variable.
Related
- The "export" keyword was removed in Godot 4
- Invalid access to property or key on a base object of type 'null instance'
- Every verified Godot 4 answer
- The "tool" keyword was removed in Godot 4: use @tool
- How to wait in Godot 4: "yield" was removed, use await
- Invalid assignment of property or key with value of type on a base object of type 'Nil' in Godot 4
- Invalid access to property or key on a base object of type 'Nil' in Godot 4
- setget in Godot 4: Expected end of statement after variable declaration, found "Identifier" instead
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free