[Problem] Score sys - not working

Hello everyone ! Im having a problem with my score system for my 2D Game.
My code goes like this

var score : int = 0;

function Start () 
{

}


function OnCollisionEnter(theCollision : Collision)
{
    if(theCollision.gameObject.name == "Score")
    {
        Debug.Log("Pokupljen score!");
        score = score + 1;
    }
}

function OnGUI () 
{
    GUI.Label(Rect (10, 10, 100, 20), score.ToString());
}

I created a object and called “Score” i put the script on my player but it doesn’t work ! Pleas help me ! Thank you :slight_smile:

You have not stated what does not work. We are not mind readers :slight_smile:

When i touch my Score it doesn’t update it steal says 0 and it needs to say 1 do you understand me ? sry for bad english

Does it show the debug message? If not put

Debug.Log(theCollision.gameObject.name)

before

 if(theCollision.gameObject.name == "Score")

Note that collision events are only sent if one of the GameObject also has a non-kinematic rigidbody attached.