This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

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():
    UpdateUI()


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

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 = Skill_Class.skill.new()

    sense_skill.name = "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> home.gd:13 @ UpdateUI()
                home.gd:9 @ _ready()
in Engine by (13 points)

1 Answer

0 votes

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.

by (22,704 points)

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.