You're first changing the value of the fuel
-variable in the singleton. And then print the value of the localfuel
-variable in your character script. The latter is a simple copy of the Singleton's value, not a reference! So it won't change along with the other.
var fuel = Global.fuel
func _process(delta):
if Input.is_action_just_pressed("button"):
Global.fuel -= 10
print("Global: ", Global.fuel)
print("Local: ", self.fuel) # explicitly local
print("Local: ", fuel) # implicitly local
Also if you provide any code, please make sure, it's formatted properly and doesn't contain any typos (like the comma instead of a dot in Global,fuel
). That will make it a lot easier for others to read through your code and help you faster.