It is not possible to invoke an expression of type 'int'.

hi everyone, im trying to make, when an enemy dies you get 100 points and it updates the gui, so every kill you get 100 and it ads up. but i get this error It is not possible to invoke an expression of type ‘int’.

here is my script.

static var pointscollected = 0;
var moneyGUI : GUIText;
var amountPoints = 100;

function update () {

if(CharacterDamage.Addpoints == true){
pointscollected += amountPoints;
moneyGUI.text = pointscollected();
}
}

moneyGUI.text = pointscollected();

You are calling “pointscollected” as though it’s a method, but it’s just an integer.

so how do i fix this?

It looks like the trouble is when you are trying to display the integer pointscollectedas a string text, since pointscollected is not text, and just a variable you need to convert it to text before you can display it. So this line…

moneyGUI.text = pointscollected();

Should probably be more like

moneyGUI.text = pointscollected.toString();

http://forum.unity3d.com/threads/34015-Newbie-guide-to-Unity-Javascript-(long)

haha pakfront, you’re stealing my fire!