How to check if a Button connected using "pressed()" signal is pressed twice ?

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

How should i go about detecting, that a button connected to a script via “pressed()” signal is pressed twice in order to have two functions? First, which is executed when the button is pressed once and the provided condition is true else if the condition is false and the button is pressed twice execute the second function.

:bust_in_silhouette: Reply From: FlamingSpear

maybe u can use a counter

var count = 0

func _ready():
]count = 0

func _pressed(): ]count += 1 ]if count == 1: ]]#first function ]if count == 2: ]]#second function ]]count = 0 (optional to restart it)

" ] " is an indent " ]] " is a twice indent