How to call the event when the user clicks on a Button in C#?

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

When the user clicks on a button, I want to write a script on C#. How can I write?

:bust_in_silhouette: Reply From: Help me please

For this you need to use its pressed signal. Click on the button node in the scene dock panel… In the inspector select node. By default signals would be selected. Then there double click on the pressed signal. if you want then change recievers method and finally click connect. But remember the node to which you are connecting signals must have a script.

This works in both c# and gdscript.
Docs: Using signals — Godot Engine (stable) documentation in English