Why this cod not working

Godot Version

godot 4

extends Node
@onready var points_label: Label = %pointsLabel

var points = 0

func add_point():
points += 1
print(points)
points_label.text = "points: " + str(points);

It means that the points_label is null, can you make sure of it? Or just drag the node into your codes by holding CTRL to define it.

Also you can remove that " ; " symbol, as it is not nessesary.

1 Like

To complement what @KingGD said, you have to keep in mind unique names has some limitations (see more: Scene Unique Nodes — Godot Engine (stable) documentation in English) and from your print i don’t see the node you’re trying to get, so probably you’re trying to use unique names in a situation that wasn’t supported. I recommend you use groups instead.

2 Likes