0 votes
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

Godot version 3.4.5? is that the latest?
in Engine by (12 points)

1 Answer

+1 vote

where is the "number" being stored and used?

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

by (53 points)

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)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.