Help with getting a node

Godot Version

4.2.1 Stable


My code when I call the display_message() method i crashes with the error:

E 0:00:01:0212 @ _ready(): Node not found: “CanvasLayer/MarginContainer/Panel/MessageText” (relative to “/root/TutorialLevel2/MessageManager”).

heres the code for the MessageManager:

extends Node

signal message_displayed

@onready var message_text = $CanvasLayer/MarginContainer/Panel/MessageText
@onready var message_audio = $MessageAudio
@onready var message_ui = $MessageUI

func _ready():

func display_message(message: String) -> void:
	message_text.text = message
	await get_tree().create_timer(0.5).timeout
	message_text.text = "message"

Can you show your scene tree?

here it is

Ah! I bet the issue is that you’ve renamed your CanvasLayer to MessageUI, so it should be:

@onready var message_text = $MessageUI/MarginContainer/Panel/MessageText

oh my god…
anyway thanks for pointing out my stupidity

Hey, sometimes you need a second pair of eyes!

yep sometimes