Score Counter Help

Ok so here is my score counter script to put on a GUI Text

 function OnGUI(){
   guiText.text =  "Score: "+CubeScript.Counter;
}

i want it so that when i collide with a cylinder it goes up by 10 so i have this script but it is not working


    static var Counter : int = 0;

function OnCollisionEnter (myCollision : Collision)
{
   if(myCollision.gameObject.name == ("Cylinder"))
   {
      Counter++;
   }
}

firstly it wont be counter++ as you want the value to go up by 10 it will be counter+10

and to check the collision instead of checking with name its better you tag the cylinder and then check it

function OnCollisionEnter(myCollision : Collision)
{
      if(myCollision.gameObject.tag == "the name with which you tagged cylinder")
       counter+=10;
}

Hey,

I cannot check it right now but try this:

on the trigger (for example a box collider with the trigger boolean turned on)

function OnTriggerEnter(other : Collider)
{
    if(other.tag == "the tag for your player object")
    {
        GuiScript.Counter += 10;
    }

}

And in your gui script (named GuiScript.js):

static var Counter : int;

function OnGUI()
{
    GUI.Label (Rect (10, 10, 100, 20), "Score: " + Counter);
}