0 votes
extends Control

onready var scoreText = get_node("ScoreText")

func _ready():

scoreText.text = "0"

func setscoretext (score):

scoreText.text = str(score)
asked Jun 14 in Engine by unskilledmoss (14 points)

What error are you getting?

This is the error

That means get_node("ScoreText") is returning null. You likely have the node path wrong. Show what your node setup looks like.

enter image description here

I don't see any "ScoreText" node there. get_node("ScoreText") looks for a node that's a child of the node the code is running on. Since your code says extends Control, I'm guessing maybe it's on "UI"?

If you have a ScoreText node somewhere underneath your UI, then you need to use the full path to it.

Please log in or register to answer this question.

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.