if the Button is pressed the first time then it wont count = 0 but the second time it will count +=1

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

#if the Button is pressed the first time then it wont count = 0 but the second time it will count +=1, how do I put this in code?

:bust_in_silhouette: Reply From: Help me please

You can do it as follow:-

var count = 0
var first_time_pressed = false

func _on_Button_pressed():
	if first_time_pressed == false:
		first_time_pressed = true
		return
	count += 1

When the button is pressed for the first time it will make the first_time_pressed variable true and will break out of the function. When you click the button again it will add 1 to the count variable