How to give a button a function in gdscript (Godot 3)

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

I am new to the godot engine and i want to make buttons on the screen were the code is in the buton node itself, so if i replace or copy the button, it still does what i want it to do (for example: quit the game). How can i do this in GDscript?

Thanks,
Legend_Eag1e

(PS: sorry foor my bad english)

:bust_in_silhouette: Reply From: GameVisitor

You add a (any) node to your scene, then right click on it => Attach script

The dialog that opens, feels like you can only create a new .gd script, however, if you select an existing (valid) one, the OK button will change to load and thus you can attach same script for different nodes (of same type, ex: Button)