Skip to content

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.

AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.

Intel or AMD Chromebook, with Linux turned on.

Download for macOSDownload for WindowsDownload for Linux

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.

More on this: The "tool" keyword was removed in Godot 4: use @tool

Reproduce it

A Godot 3 onready variable in a Godot 4 project. The scene is one Node with a Label child.

More on this: Invalid call. Nonexistent function '…' in base 'Nil' in Godot 4

GDScript
extends Node

onready var label = $Label

func _ready():
	print(label.name)

What Godot 4.7.2 prints

Output
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.

GDScript
extends Node

@onready var label: Label = $Label

func _ready() -> void:
	print("found ", label.name, ", a ", label.get_class())

What the fixed script prints

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

found Label, a Label

Run this fix with your agent

Flockbay is the Godot editor with an AI agent built in. Paste this into Flockbay's chat, or into Claude Code or Codex connected to Flockbay over MCP: the agent finds the cause in your project, applies the fix, runs the game headless and reads Godot's output to check it.

Prompt
My Godot project was written for Godot 3 and Godot 4 stops on this: "Parse Error: The "onready" keyword was removed in Godot 4. Use the "@onready" annotation instead.". Port every use to Godot 4. 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. Then run the game headless and check Godot's output for errors.

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_parser.cpp line 1201, the message.

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.

Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.

Download Flockbay free