I cant figure out why im getting an error

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

onready var scoreText = get_node(“ScoreText”)

func _ready():

scoreText.text = "0"

func set_score_text (score):

scoreText.text = str(score)

What error are you getting?

kidscancode | 2020-06-14 23:00

unskilledmoss | 2020-06-15 15:21

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

kidscancode | 2020-06-15 15:24

unskilledmoss | 2020-06-16 16:46

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.

kidscancode | 2020-06-16 17:34