cannot get tree from a node that is in it???

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

UPDATE:
i solved it, i was making an instance of it so it couldn’t reach the tree…
yeah rookie mistake

tree:
-Node2D
–Player (kinematicbody)
–Node2D

i’m trying to call get_tree() but it returns null (from the player script)
i searched online and everybody says the node must be in scenetree but it is in it.
what do I do?

tree:
-Node2D
–Player (kinematicbody) ==> script is here
–Node2D ==> you want to access this (change node name. example = Node_two)

onready var node_two = get_parent().get_node("Node_two")

ramazan | 2022-08-27 09:10

it says

Attempt to call function ‘get_node’ in base ‘null instance’ on a null instance.

51m0n55 | 2022-08-27 09:12