You initially create coins
as an int with coins = 0
. However, in your ready
function, you overwrite that value with an object from your scene tree with this:
coins = root.get_child(root.get_child_count() - 1)
What are you trying to do there? That's really where your problem is, as coins
is no longer an int
after that happens, so your later Global.coins += 1
fails.