get_node: node not found

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

I’m using a scene to act as a scene changer, but in its script, it’s unable to find it’s child nodes.

My structure is like so:


The two lines of code i use are

onready var animation_player = get_node("AnimationPlayer")
onready var black = get_node("Control/blackRect")

Without fail, they result in a get_node: “node not found” error. This doesnt crash the program, but when I try to call them later, the null pointer does.
I have tried:


Is this an autoload? Did you autoload the scene or just the script? If you autoload the script, it has no child nodes, so this situation will occur.

kidscancode | 2020-04-22 17:53

Yes, it is an autoload, and I was loading the script not the scene… I should’ve seen that. Thanks for the help, much appreciated!!

Kore-rep | 2020-04-22 18:31