Topic was automatically imported from the old Question2Answer platform.
Asked By
brgenmod
I have done a function that changes the text of a Label, it works perfectly the first time, after the first time, the following error appears: “Attempt to call function ‘set_text’ in base ‘null instance’ on a null instance.”
How do I fix this? Thanks in advance.
Code: " func function(): variable -= 1 get_node("../Label").set_text(str(tentativas)) pass var variable = 0 func _ready(): variable = 0 "
Your code is formatted strangely. Use the “{}” button to format the code properly.
null instance errors are usually caused by a bad node reference. Are you sure “…/Label” is the right path to the node? That would mean the label is a sibling of the current node.
This error : “Attempt to call function ‘set_text’ in base ‘null instance’ on a null instance.” means that the godot cannot call the ‘set_text’ function because it finds nothing (or null) is in the ‘get_node(“…/Label”)’
or to be simple, the godot program cannot find your node…
usually it is because you write the wrong node name (Uppercase,lowercase, etc) or wrong node path