Need help with a error

I am trying to make it so that when you pick up an item it adds a number to your score. It was working fine a few days ago but today when I tested the game it kept giving me an error. I didn't change anything since it was working so I have no idea why it just stopped working.

Here is my error, hope someone can help me.

Error running script: Error compiling expression 'player.score + 1928': ArithmeticElement: Operation 'Add' is not defined for types 'Object' and 'Int32'


What does the code look like for this function?


there's an issue with your 'player.score', either:

  1. you don't have a 'player' Player Object (either deleted it, renamed it, toggled it off from being a Player Object - well actually this wouldn't cause the error, so nevermind on this last thing about toggling your 'player' Object from not being a Player Object)

  2. you don't have a 'score' Integer Attribute (either you deleted it or you toggled it off in the GUI/Editor, look under the 'game' Game Setting object's 'Features' Tab, I think) on your 'player' Player Object. If you have a 'player' Player Object, then under its 'Attribute' Tab, at the bottom of the screen is the Attributes box, look in it for a 'score' Attribute, and if you have it, make sure it's type is that of an 'int (integer)'.

  3. otherwise, maybe it's an issue with your scripting syntax, in that you didn't do-it-right/set-it-right (in code, it should look like this: player.score = player.score + 1928, in GUI/Editor, like this: set variable player.score = [EXPRESSION] player.score + 1928)


It is number 2. on HK's list; the score attribute does not exist.


did you not save your file after you got the code working the other day?


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums