extends Control var score = 0 @onready var label = $Label #or get node they both dont work
# Called when the node enters the scene tree for the first time. func _ready() → void:
** pass # Replace with function body.**
# Called every frame. ‘delta’ is the elapsed time since the previous frame. func _process(delta: float) → void:
** score +=1**
** label.text = str(‘Score:’)**
** strong text**
please tell me how to solve the problem
this gives error:
Invalid assignment of property or key ‘text’ with value of type ‘String’ on a base object of type ‘null instance’.
label is null(cant find it maybe)
i checked if it exist and the path is correct.can you help me :
As a habit I like to name the script the same as the node it is attached to.
In your case your top level node is not yet given a name (Control) but the attached script is may be called ‘score.gd’. Is the ‘score.gd’ script attached to the ‘Control’ scene node?
And is the Control node script the one you are running? I can’t tell from the image.
Alternatively…
Is it possible you are running the score.gd script in more than one place?
Do you have it attached to any of the other nodes or even as an autoload?