# Unity Game Score Script

**URL:** https://discussions.unity.com/t/unity-game-score-script/28663
**Category:** Questions & Answers
**Created:** [September 19, 2011, 3:25am UTC](https://discussions.unity.com/t/unity-game-score-script/28663 "2011-09-19T03:25:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![system](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/system/32/97283_2.png) [@system](https://discussions.unity.com/u/system)
#### Post date: [September 19, 2011, 3:25am UTC](https://discussions.unity.com/t/unity-game-score-script/28663/1 "2011-09-19T03:25:15Z")

</div>

I’m making a game where by clicking the moving target your gain points. I’ve got in figured out a little but the code isn’t responding. What am I missing? What code will help me have the score total appear on screen? I’ve looked all over and other scripts have not work for my application.

Moving object Script:

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

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

function Update () {
}

```

---

<div class="post-metadata">

### Author: ![aldonaletto](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/aldonaletto/32/44226_2.png) [@aldonaletto](https://discussions.unity.com/u/aldonaletto)
#### Post date: [September 19, 2011, 3:51am UTC](https://discussions.unity.com/t/unity-game-score-script/28663/2 "2011-09-19T03:51:57Z")

</div>

This code only sets the score text to buck when you press the left mouse button over the object to which the script is attached.

If you want to add 1 to buck when the object is clicked, you should modify this code:

```
var buck : int = 1;
var ScoreBoard : GUIText; // <- drag your GUIText here

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