Problem with GameObject selection script

I am trying to make a script that will let you click on a game object and select it.

var IsSelected : Boolean;

(Input.GetMouseButtonDown(0)){
   //Iselected = true;
}

And I attached it to a cube, but know matter where I click in the game it will select it.

You code only checks whether the player has clicked the mouse, not whether the mouse is actually pointed at the object (you need both to be true).

Look into raycast selecting.
This question has the answer for you already. Please look before you ask.