How to fix Null instance

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

Every time im trying to do something with a node (like $node.global_position or something like that) i get error with null instance (invalid get index ‘global position’ (on base:‘null instance’). I looked in the interned and found what this error may occur when script is unable to get the node. Am i doing something wrong and how do i fix that?

:bust_in_silhouette: Reply From: kidscancode

“null instance” is what you get from get_node() when you give it an invalid path.

If you’re getting this error, it means that you are not using a valid path to get the node you want. It’s impossible to tell you exactly what you’re doing wrong because you haven’t showed your node setup or where in your code you’re trying to access the node. Regardless, you must give the correct node path in order to get the node.

It’s important to understand how node paths work. If you’re familiar with the directory structure of your operating system (Windows, MacOS, Linux), they work in exactly the same way.

This link may help you with understanding how to get a node: