extends Node2D
var val = 150
func _restrict(amount):
var outcome
if val < 0:
val += amount
$Label.set_text("You don't have enough money.")
outcome = false
else:
outcome = true
return outcome
func _substract(amount):
val -= amount
var outcome = _restrict(amount)
func _add(amount):
val += amount
Code in Continue:
extends TouchScreenButton
onready var amount_to_continue = 50
func _ready():
pass
func _on_Continue_released():
var currency = get_node("../Currency")
var outcome = currency._substract(amount_to_continue)
if outcome:
_continue_with_game()
Then adjust and complement that kind of logic for your game.