Attempt to call function 'connect' in base 'null instance' on a null instance.

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

For whatever reason, the $ isn’t finding the sprites on the left. I checked the spelling & everything, it seems to be perfect. maybe i don’t know how to use “connect”. Why do I get this error message & how can I fix it?enter image description here

https://drive.google.com/drive/folders/1CVQK5YHudM8G1Synq1NRIzxOU14KgikH?usp=sharing

:bust_in_silhouette: Reply From: kidscancode

Because you are not using correct node paths. I’m assuming this script is on fighter.

Writing $fighter means get_node("fighter"), which means “Get a child of this node named ‘fighter’”. fighter doesn’t have a child named “fighter”, so you get a “null instance”.

In addition, you’re also trying to use $fighter2, which also isn’t a child of the scripted node. The path from fighter to fighter2 would be "../../fighter2/fighter2". I don’t know why each of your Sprites has a Node2D parent, but that’s another issue.

If you’re having trouble understanding node paths, you might find this helpful:

http://kidscancode.org/godot_recipes/basics/getting_nodes/