Error when trying to connect signal

Whenever I press the spacebar to shoot a rocket, the game stops and shows the error message: “Attempt to call function ‘connect’ in base ‘null instance’ on a null instance.”
I was following the tutorial step by step, and everything was fine until this section.
I’ve double-checked multiple times, but I’m still encountering the error. Does anyone know what might be wrong? Thank you!

Aha, looks like a misleading error message. I don’t think your problem lies in this part of the code; Instead, look at wherever you are instantiating rockets. This error suggests that your rockets are either not instantiating properly or are not being added as children to the node tree, since it can’t find a rocket to call connect() on.

2 Likes

Thanks for responding to this student, I agree with you looks like there is a problem with the rocket being instantiated or where it is being instantiated so it cannot use the connect signal for when it exits the screen.

I suspect the problem is in the shoot function.

2 Likes

Thank you BH67! I double checked outside my code, and found another rocket.tscn file in the root folder (also have one in scenes folder). Don’t know how I have two files though. I deleted the one in root folder and cleaned the code in another one. Now everything works! :smiley:

2 Likes

Thank you Marc! The error is gone as I deleted a duplicated rocket.tscn in the root folder.

1 Like

Glad you managed to find a solution to this issue :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms