get_tree() returns the SceneTree, not whatever your Main node is. You need to get the node using get_node() and whatever the path to the node is.
You can use get_parent() to get the node’s parent.
I tried $ which is the same as get_node() or that’s what I’ve read but it didn’t work gave me an error about an invalid instance but get_parent() works thanks.
One more question what if it was the grandchild I would have to do: get_parent(get_parent()) is there a way to get the root node from wherever?
IHate | 2019-06-25 05:16
$ and get_node() are interchangeable, but if you want to go up a level, it would be get_node("..") or $"..". To go up multiple levels, you’d use get_node("../..") etc.
get_tree().root will get you the root viewport, so you can get your main node from that:
get_tree().root.get_node("Main") for example.
All this said, it’s typically a bad idea to be going up the tree. It means you’re not going to be able to move nodes around because they expect a fixed parent structure. It’s much more flexible to call down the tree, and use signals if you need to go up.