Why doesn't get_node() work?

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

Hi guys,

I recently converted from Unity to Godot, so forgive me if this is a stupid question.

I’ve been trying to access two nodes from a script attached to an empty root Node using get_node():

extends Label

var rgb = 0

func _process(delta):
    rgb += 0.02
    get_node("Label").set_modulate(Color(rgb,rgb,rgb,1))
    if get_node("Label").get_modulate == Color(1,1,1,1):
        get_node("Banner").visible = true

Whenever I try to run this script, I get an error telling me these two child nodes can’t be found.

Here’s a link to the scene tree as it appears the editor (the script is attached to Root):
Scene tree

Do you have any suggestions as to why this might be happening?

Thanks in advance

Edit: So I redid the scene tree and all of its nodes and the get_node() method spontaneously started working again. Weird.

:bust_in_silhouette: Reply From: volzhs

I think you should get error on the first line extends Label
this should be extends Node

Thanks for your suggestion.

I’m afraid that doesn’t work though. It still just gives me an error for not being able to find the child node with get_node().

skullkid | 2019-07-04 20:37