How to connect a signal in GDScript without specifying the source code.

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

I am making a game where there are multiple buttons on the screen. When clicked they execute a function and then send out a signal. The main code should react in the same way no matter which button is pressed. Seeing as the name of the signal is the same for all of them it would be very convenient to connect this signal in code without specifying from which node it originates. I could not find anything useful in the documentation.
Is this possible?
P.S. Sorry if this is a very basic question but I am just getting started with Godot.

:bust_in_silhouette: Reply From: Bot7

I think you should take custom signals like:

signal test

func _on_Button1_pressed():

func _on_Button2_pressed():

func _on_Node_test():
print(“hello World”)