Cant find node in the tree

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tiez

image hosted at ImgBB — ImgBB Here is a link to the SS

I have been trying to access a console node from tree. Clearly node path is correct but godot doesnt get it.

Here is my code:

onready var console = get_parent().get_node(“Player/CanvasLayer/console”)

func _physics_process(delta):
print(is_instance_valid(console)) <---- dis line keeps outputing false

I think the problem is console isnt in the tree when game launches. its instanced when player presses the console_toggle button. But as you can see when console node is instanced to the scene tree, line i mentioned above still returns false, and when i get rid of /console after canvaslayer it returns true.

:bust_in_silhouette: Reply From: ReudsFratt92
onready var console = getparent().getnode("Player/CanvasLayer/console")

=>

onready var console = getnode("Player/CanvasLayer/console")

try this
or this:

onready var console = getnode("CanvasLayer/console")

depending on context. Try adding “/” in the beginning as well

Nope, still same error message

Tiez | 2022-07-11 12:33

nothing is working, is this a bug or something

Tiez | 2022-07-11 12:36

:bust_in_silhouette: Reply From: Tiez

Nevermind i’ve found the solution. It was very stupid, console node wasnt in the scene tree initialy so i had to get a node to canvaslayer, and then console.get_node(“console”)