What is wrong with this code?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Arcane
func _on_AC1_pressed():
	if number > 24:
		print("PURCHASED")
		number = number - 25
		queue_free()
	
	
	
	else:
		print("CANT AFFORD NEED 25")

It is meant to take away 25 but its not

:bust_in_silhouette: Reply From: petermoyle

where is the “number” being stored and used?

Surely if you queue_free() the object is destroyed and “number” will be gone?

Indeed, if number is stored in the node that’s being deleted when the number reaches 25, that’s your problem. You may want to store the number in another script (that isn’t attached to a node being deleted)

godot_dev_ | 2022-09-02 15:42