set text was working normally now getting error

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SugarBeetle

in my score script I’m getting the Invalid set index ‘text’ (on base: ‘null instance’) with value of type ‘String’." on the line where I’m setting my text $score.text = str(score)

extends Control

var winscore: int = 50
var superwin: int = 100
var score: int = 0

func _ready():
	Signals.connect("on_score_increment", self, "_on_score_increment")

func _on_score_increment(amount:int):
	score += amount
	$score.text = str(score)

I’m confused as it was working fine a few moments ago, and the game jam I’m entering ends in a few hours. Any help is welcome, thank you!

Did you move the node ‘score’ thats what returning null

Asthmar | 2022-09-25 18:54

:bust_in_silhouette: Reply From: jgodfrey

Looks like you have a int variable named score that’s (apparently) used to track the current score. However, you’re also trying to set the text property of some control named score.

Both of those unique things can’t be named score

What is the correct reference for the score display control?