Attempt to call function 'set_text' in base 'null instance' on a null instance.

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

Plz help! I have no idea what to do, and this make me insane. Godot just don’t wanna see my node. I was trying to code this by many variant, but nothing is working. By the way it’s problem not alone in my project. If you help me, you probably help me to finish my game. THX.
CODE:
extends Control

func fail():

var scr
var HUD = load("res://hud.gd").new()
scr = HUD.score
get_node(".../Score").set_text("SCORE: "+str(scr))

func _ready():
pass

NODE TREE:
Node2D->Controll->Panel->Score

:bust_in_silhouette: Reply From: kidscancode

".../Score" is not a valid node path. If you’re trying to get a node that’s a sibling of this one, you would use "../Score". “…” means “the node above this one”. “…” has no meaning.

You also don’t need to use set_text() btw. Properties are accessible directly.

get_node("../Score").text = "SCORE: "+str(scr)

Thx! It’s working!

Jasper | 2020-07-14 18:30