Can't change label text

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

So I’m trying to change a label’s text. Currently, both the labels I am trying to change are grandchildren to the node that is trying to change them. This is temporary as right now I am just trying to make sure and see that the system works and is output to the scene.

Now to the actual issue. Whenever I try to run the program it tells me it can’t find the node

func _ready():

func UpdateUI():
	$Character/QiLabel.text = "qi: " + str(qi)
	$MainMenu/Skills/Skill1.text =

For the first one, I am not sure what the issue is as it worked before and now it doesn’t
as a matter of fact, when I bypass the error for both lines I do see that it does indeed display correctly

For the second one, it also gets the same can’t find node error however as long as I change the text to something else and bypass the error I do see it change the text in-game. . . However, I also have another issue in which I am not sure if I am referencing the name correctly. for context the second one is referencing this on a different script.

func sense_area():
	var sense_skill = = "Sense Area" 

Edit: you don’t have to answer that second question as I can figure it out myself as long as the first issue is fixed however if you have an answer I wouldn’t mind hearing it.

also here is the error that I am getting in Godot if it helps.

E 0:00:00.773   get_node: Node not found: Character/QiLabel.
  <C++ Error>   Condition "!node" is true. Returned: __null
  <C++ Source>  scene/main/node.cpp:1381 @ get_node()
  <Stack Trace> @ UpdateUI()
       @ _ready()
:bust_in_silhouette: Reply From: jgodfrey

So, if you’re getting a Node not found error, but the labels are still displaying the text as expected, I’d guess that the above script is (unintentionally) attached to multiple nodes in your scene. The instance that’s attached to the correct node is working, and updating your label text as expected while the instance(s) attached to other nodes (that sit elsewhere in the tree) are unable to find the nodes as specified in the script - which generates the mentioned error.

Just a guess, but that’s what I’d look for.

Thanks yeah after asking I descoverd it’s because I had turned the script into a Singleton.

riseofevillink | 2020-12-04 20:52