I have a working auto clicker script for my cookie clicker game, but it only updates when I click

Godot Version

4.72

Question

Does anyone know what I have to change so it updates every time its suppose instead of me clicking I cant find any solutions for this.

extends Button

var price_of_clicker = 100
var clicker = 1
var amount_of_clicker = 0

signal Amount_of_clicker_changed

func _pressed():
	if Global.Cookie >= price_of_clicker:
		Global.Cookie -= price_of_clicker
		price_of_clicker *= 1.5
		amount_of_clicker += 1
		emit_signal("Amount_of_clicker_changed", amount_of_clicker)
	else:
		print("You dont have enough money to buy a clicker")
		return


func _on_amount_of_clicker_changed(amount) -> void:
	if amount >= 1:
		print("Success")
		while true:
			await get_tree().create_timer(1).timeout
			print("hello")
			Global.Cookie += amount * clicker
extends Button

signal Clicked


func _pressed() -> void:
	Global.Cookie += Global.Cookiesonclick
	emit_signal('Clicked', Global.Cookie)
	#this is for my text label unreleated to the other script#

You need to give more information in all of your posts. What does “every time it’s supposed” mean? You must always explain what you expect to happen versus what is really happening or we have no idea what the problem you are trying to convey is.

This looks like you should be using a Timer node instead, and connect to it’s timeout signal.

If you want to print(“Hello”) every frame, maybe try using this function

func _process(delta: float) → void: