HELP it cant find the node even though it exists

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

I’m trying to make a stamina bar but when I try to set its percentage it cant find my stamina bar node.

my code:
extends TextureProgress
var stamina = 0

`extends TextureProgress
var stamina = 0

func _process(delta):
$STAMINA2.value = stamina
if stamina <= 100:
stamina += 1delta
if Input.is_action_pressed(“sprint”):
stamina -= 10
and the error I get is:
get_node: (Node not found: “STAMINA2” (relative to “/root/Level1/STEVE/Node2D2/STAMINA2”).)

That $STAMINA2 reference requires that the STAMINA2 node is a direct child of the node containing the above script. I can only assume that’s not the case here. If you can’t get it working based on that, you’ll probably need to share the structure of your current scene tree as well as indicate which node the above script is associated with.

jgodfrey | 2022-03-01 16:41