scoreboard

i have a score script but i dont know how i can make that the player can see his score

script:

var Score : int = 0;
 
function ObjectCaught(enemy) {
    Destroy(enemy);
    Score++;
}

var scoreRect:Rect;
function Start(){
scoreRect = new Rect(Screen.width/4*3,Screen.height/4, Screen.width/20, Screen.height/20);
}
function OnGUI(){
GUI.Box(scoreRect,Score.ToString());
}

What it does is create a box in the top right corner. Then it displays your score in it.
Add this on your existing script.

Note the Rect, the values are not hardcoded, meaning you are using the screen dimensions so that if you use on a tiny screen, the box is tiny too.