Connecting Signals from a Newly Spawned Child to Parent

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

I looked online for help with this problem. I saw a solution, which was using the connect() line, and I used it when I spawned the child - Tower1.connect(“death”, get_parent(), subtract_units1()) and subtract_units1() is a function I created previously. It says “Invalid type in function ‘connect’ in base ‘Node2D (Node2D.gd)’. Cannot convert argument 3 from Nil to String.” Could someone help me?

Ok, so I solved it, but a new problem has arrived. I changed the line to

Tower1.connect("death", get_parent(), "subtract_units1")

Now the program isn’t crashing, but the function doesn’t do its job. Could someone help me?

ThreeSpark | 2018-11-05 00:08

:bust_in_silhouette: Reply From: markopolo
Tower's Grandparent
--Tower's Parent
  --Tower

I’m assuming you are calling connect() from the Tower’s Parent, which means get_parent() returns the parent of the tower’s parent, i.e. the tower’s grandparent. Does the tower’s grandparent have the subtract_units1 function?

As an aside, are there any error messages in the debugger? That’s what tends to happen when there’s a signal connection mishap.

I… I just realized… that… I should… have used… self

ThreeSpark | 2018-11-05 00:43