Changing the Color of an object during runtime using ray casts

Just want it so that when the ray cast hits the cube (with a red material) it turns to blue. I am successfully using the ray cast, but getting no result with change colour.

//Raycast against tiles
 	var fwd = transform.TransformDirection(Vector3.forward);
	var hit : RaycastHit;  
   if(Physics.Raycast(transform.position, fwd, hit, 10))
   {
      Debug.Log("Hit"); 
      	if(hit.trigger.gameObject.name == "Red")
      	{
     	 print ("Hit Red Box");
      	renderer.material.color = Color.blue; //Obviously didn't work
	    }   
   }
   
   Debug.DrawRay(transform.position, fwd * 10, Color.green);
   
}

Thanks, guys.

Try this one, because you were not trying to change the color on the object you hit, but on the object you were raycasting from.

hit.collider.renderer.material.color = Color.red;

Whenever i get a collision the console comes up saying:
“MissingFieldException: Field ‘UnityEngine.RaycastHit.trigger’ not found.”