This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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!

Godot version 3
in Engine by (21 points)

Did you move the node 'score' thats what returning null

1 Answer

0 votes

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?

by (22,704 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 Frequently asked questions and 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 [email protected] with your username.