Basic signal experiment failure

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

I am trying to understand how signals work. I have two scenes, Main, and Scene01. Both have root nodes Main and Scene01. Both of these nodes have scripts attached. An instance of the Scene01 node is a child of the Main node.

The script attached to the Scene01 node is this:

extends Node

signal send_to_main

func _ready():
	print("Scene01 _ready")
	emit_signal("send_to_main")

The script attached to the Main node is this:

extends Node

func _ready():
	print("Main _ready")
	self.connect("send_to_main", self, "_message_received")

func _message_received():
	print("Received message")

Why does “Received message” not print?

:bust_in_silhouette: Reply From: volzhs

you need to connect signal to the node which emit signal like

$Scene01.connect("send_to_main", self, "_message_received")

instead of self