how to access variable from first node in tree?

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

what i want to do is ,when i instance node under (creation)node.
my instance node will look for var in first node in tree.
i dont want do like this get_node("character_selection") because i can only access in this scenes. there other way to do

get_tree(),get_root().get_node("character_selection")

enter image description here

:bust_in_silhouette: Reply From: bloodsign
onready var creation = $creation

func test():
  if creation.get_child(0).has_method("get_variable"): 
    print(creation.get_child(0).get_variable())  

func _ready():
 test()

parent.get_child(n) where n is the index of that parent’s children.
Visit this for more detailed info Node — Godot Engine (stable) documentation in English