0 votes

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 "

in Engine by (12 points)

2 Answers

0 votes

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.

by (20,315 points)
0 votes

This error : "Attempt to call function 'settext' in base 'null instance' on a null instance." means that the godot cannot call the 'settext' 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

by (39 points)
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 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 webmaster@godotengine.org with your username.