How Do You Select A Game Object By Using the Left Mouse Button?

Hey everyone I am trying to make a game but one of the main parts to it is selecting game objects with the left mouse button. I was wondering if anyone knew the java script to allow you to click on a game object and the game object change color or something as a result. Also just to mention I have very little experience with this and have done little to no coding/scripting or whatever it is called. I have checked google and the results I have found have been of little help due to my inexperience. Also does anyone know how to make this work for prefab or instantiated objects too? Any help is appreciated.

https://www.google.com/search?q=Select+A+Game+Object+By+Using+the+Left+Mouse+Button

Does anybody read the docs? Unity - Scripting API: RaycastHit.collider

A common method is to use Raycast in a camera script, and change the hit object properties - like this:

var hitTransform: Transform; // transform of currently selected object

function Update(){
  if (Input.GetMouseButtonDown(0)){ // if left mouse pressed...
    // create ray passing through the mouse pointer:
    var ray = camera.ScreenPointToRay(Input.mousePosition);
    var hit: RaycastHit;
    if (Physics.Raycast(ray, hit)){ // if something was hit...
      hitTransform = hit.transform; // get a reference to its transform
      //
      // and do whatever you want with this object here
      //
    }
  }
}

The variable hitTransform holds the transform of the last object clicked.