How to edit button text using scrpit?

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

I would like it so then when I press a button, its text will change.
I have tried doing

 func _on_Button_pressed():
        $Button.text = "hello"

and also $Button.text = str("hello")

but neither work

:bust_in_silhouette: Reply From: kidscancode

That first function looks fine. Did you connect the button’s pressed signal to it? The function alone won’t do anything.