Assets/Points & Pickup.js(24,10): BCE0044: expecting (, found 'OnGUI'.

I'm using the points system that i found on here, it worked well until i wanted to add a second 'coin'. I've looked at it, my friend looked at it, and we cannot figure out what is causing this error, chances are it's gonna be staring us in the face..

var score = 0;
var scoreText = "Score: 0";
var mySkin : GUISkin;

function OnTriggerEnter( other : Collider )
{
Debug.Log("OnTriggerEnter() was called");
if (other.tag == "Coin")
{
Debug.Log("Other object is a coin");
score += 1;
scoreText = "Score: " + score;
Debug.Log("Score is now " + score);
Destroy(other.gameObject);
}
else
{
score +=5;
scoreText = "Score: " + score;
Debug.Log("Score is now " +score);
Destroy(other.gameObject);
}

function OnGUI () {
GUI.skin = mySkin;
GUI.Label (Rect (10, 10, 500, 200), scoreText.ToString()); }

1 Answer

1

You're missing the end } for OnTriggerEnter - the last one there ends the else

Small note - correct indenting will make this kind of error easier to spot