Delay not working

i’m trying to make a tower defence game, when i tried to setup a auto coin increaser, it just goes to max straight away for some reason.

extends Node2D

var coins = 0
var maxcoins = 1000


func _ready():
	increasecoins()

func increasecoins():
	while coins < maxcoins:
		get_tree().create_timer(100).timeout
		coins = coins + 1
		$CoinDisplay/Label.text = str(coins) + "/" + str(maxcoins)

i mean it work but it’s too fast and the wait doesn’t seem to work on this

You need to put a await keyword before your get_tree().create_timer(100).timeout:

await get_tree().create_timer(100).timeout

1 Like

lol even i just realzed it XD, i was about to delete this post lol but u already replied