Score Counter

I have a JavaScript and i want to add a counter to my game. I have a script added to my Character but it doesn’t count the score.
How do I do fix this?

JavaScript:

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

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

Counter:

var MenuSkin : GUISkin;
var toggleTxt : boolean;
var toolbarInt : int = 0;

function OnGUI() {
    GUI.skin = MenuSkin;
    GUI.BeginGroup(new Rect(Screen.width/2-150,Screen.height/100-0,250,50));
        GUI.Box(Rect(0,0,250,50),"Score: ");
    GUI.EndGroup ();
}

So for some reason, you don’t want to merge those two scripts. I guess you they are on two different objects.

You need a reference of the instance of the first script into the second one to access it’s score variable. Declare the var at the beginning of the Counter script, then drag-drop the gameObject containing the first script onto that variable in the inspector of the second object.