system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
grol |
|
Old Version |
Published before Godot 3 was released. |
Hey there,
I try to set the text of a label but get the following error:
Attempt to call function 'set_text' in base 'null instance' on a null instance.
I use the following code:
get_node("info").set_text("test")
Any ideas?
system
4
|
|
|
|
Reply From: |
batmanasb |
Your get_node(path)
failed to find the path to the node and returned “null”. Make sure the path is correct.
system
5
|
|
|
|
Reply From: |
turgotZ |
Depends on where you are using that code in relation to the node you want to change?
- If the node info has the script attached try just
set_text("test") or self.set_text("test")
- If your script is attached to a different node which is within (child of info ) try
get_parent.set_test("test")
- If node info is a sibling to the node with the script try
get_node("../info").set_test("test")
The structure of nodes is the key.
Thanks guys,
I really thought the node names are absolute and i can call them from anywhere.
Now I understand.