Invalid operands 'object' and 'int' in operator +

Godot Version

4

Question

I wrote the “var Coin_score”, and then I made a code like this.

But I faced to the error “invalid operands ‘object’ and ‘int’ in operator +”

How can I declare the Coin_score to make it as type of int?

image

Where you currently write var Coin_score to declare the variable, try writing this instead:

var Coin_score: int = 0

If that doesn’t work, can you share more of your script so it’s easier to spot the specific problem? Only the _on_coin_area_entered function you’ve shown isn’t enough on its own to be certain that this is really going to fix it.

1 Like