raycast to object, load wrong script!?

When pressing object to load level, it loads wrong level and randomly. Same script at all 3 balls. only loadlevel different. Why does it load wrong level?

I also added the project, its 287kb.

function Update () 
{

    if (Input.GetMouseButtonDown(0))
    {
        var hit : RaycastHit;
        var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, hit))
           {
           Application.LoadLevel ("Blue");
           }
    }
  
 }

Because all three scripts say if anything is hit then load - whichever one gets to go first loads the level

You are probably looking for

function OnMouseDown()
{
     Application.LoadLevel("Blue");
}

Or preferably:

 var levelToLoad : string;

 function OnMouseDown()
 {
    Application.LoadLevel(levelToLoad);//Set this in the inspector
 }

thank you very much, make sence now when you say it and easier script! :slight_smile: