How to delay a function to begin with, then repeat it constantly.

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

How do I get to so you have to wait 3 seconds for it to start printing ha but after the first “ha” it prints it out every 0.3 seconds

var stop_loop = false
func _on_Button_button_down():
stop_loop = false for n in 999: yield(get_tree().create_timer(3), "timeout")
if stop_loop: return else: $Label.text = $Label.text + "ha"

:bust_in_silhouette: Reply From: Inces

with 2 yields.

for n in 999: yield(0.3) and print