So I am trying to set the coins variable to +=1 when it enters the area. I can use the constant GROUP_ROCKET , but using the game.coins += 1 outputs : Invalid get index 'coins' Here is all you need to see:

Hi gurgu22.

Sounds like you are accessing something uninitialized. What is the base of this error or is it the complete error text? Is game really initialized (print/debugger)?

Independent of you problem, I would not recommend to change variables in other scripts directly (I don't really know if it is possible this way). It could lead to accessing problems (threading for example). A better way could be to use setget and functions to set or get this value within the script itself. Instead of this I would change it via a function call or (maybe better) via signals. You could define a signal in your coin.gd script, connect it to your game var and handle this signal within your game.gd script.

Cheers Z3R0PTR

3 years later