How i can't get reference to node even if its clearly in the scene tree?

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

enter image description here

Sorry for probably being dumb, but i cant figure this out. I tried many times, and I still get simmilar errors with “get_node(Node not found)…”.

I tried function below to check the values of changing variable (deleted most of old code).

func _process(_delta) -> void:
print(maxval)

I changed value by using either function _on_plus_pressed() or _on_minus_pressed and it started printing me two values:

  1. defualt value(8)
  2. value after changing it

Hmmm… I don’t see anything obviously wrong in your project setup - though, I’m confident there IS something wrong :).

Is the project available somewhere for inspection?

jgodfrey | 2022-08-11 20:08

Any chance you can press the “>” in the debug window and reupload the pic?

dacess123 | 2022-08-12 11:38

Is your Controls.gd an autoload by any chance? If so, select your .tscn file as the autoload instead.

wyvern | 2022-08-13 15:16

:bust_in_silhouette: Reply From: jgee_23_

You cannot see the error in this screenshot because it is not here. The error must be in your TrueMenu scene. You’re changing the scene completely, then trying to access the node lbl_mx_tp which doesn’t exist anymore as you changed scene.

What you could do is instead of changing the scene completely, simply add the new scene as a child of the Controls scene, then you will be able to access lbl_mx_tp from TrueMenu’s script.

:bust_in_silhouette: Reply From: imp4ct

That was my fault.
When the scene is autoloaded and name in autoload is the same as the scene curently displayed, scene name changes(curently displayed). I could see it happening in remote tab. I created new scene to store variables and added it to autoload. Then i deleted Controls from autoload and things fixed