Game Script for Mouse Click Scoring.

I’m trying to make this code to work. I want it to add points onto the GUI Text as the player uses the mouse to click the object that this script is attached to. Right now its not working.

I keep getting an error saying: “HitscoreScript.js(2,25): UCE0001: ‘;’ expected. Insert a semicolon at the end.” Do I have the code setup correctly? What am I missing? What coding do I have to have on the GUI Text object?

var buck : int = 1;
var ScoreBoard : GUIText (ScoreBoard);

function OnMouseOver () {
   if (Input.GetMouseButtonDown(0)) 
   {
        ScoreBoard.text = ("Score: ") + buck;
   }
}

function Update () {
}

1 Answer

1

Change your Scoreboard into a transform variable and get rid of the:

(ScoreBoard)

part and say

ScoreBoard.guiText.text = "Score: " + buck;

this at least what I would do and works for me. Hope it helps!