changing objects color through a raycast?

Is this possible?

My script changes the color of my player but I’d like it to change the color of anything hit that has a tag of “placedObject” also a few seconds afterwards to change the color back to normal. Could anyone help me with this? thanks.

function Update (){

if(Input.GetMouseButtonDown(0)){

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

if (Physics.Raycast (ray, hit, 10.0)){
if(hit.collider.tag == "placedObject"){

var renderer : Renderer = hit.collider.renderer;
renderer.material.color = Color.yellow;

print ("hitObject");

}
}
}
}

function Update()
{
//…
if(hit.collider.tag == “placedObject”)
{
Wait(hit.collider.renderer) ;
}
}

 function Wait(rend : Renderer)
 {
    var originalColor = rend.material.color ;
    rend.material.color = Color.yellow ;
    yield WaitForSeconds(2) ;
    rend.material.color = originalColor ;
 }