Problem wiht RaycastHit2D ! Changing hit's sprite

Hello

I want to change hit’s sprite that is in front of my player(2D) with raycast2d

But I have many objects that are the same(have one tag and name and layer) and I want that change the sprite of any these game objects that hit.

I’ve set the layer just for these game objects.
but this code do what I want just for the first hit!!

here is my code
Thanks

function WaitForGh (waitTime : float) {

		yield WaitForSeconds (waitTime);
ghermez = false;


}

function Update () {

	var hit: RaycastHit2D = Physics2D.Raycast(transform.position, Vector2.right,20,layer);

	 if (hit)
{
if(hit.collider.transform.gameobject.GetComponent(SpriteRenderer).sprite == "Ghermez")
print(hit.transform.name);
	if(ghermez){
WaitForGh(1.5);
hit.collider.transform.gameObject.GetComponent(SpriteRenderer).sprite = sabz;
}
}

Finally solved
I did it

if(hit){
if(hit.collider.transform.gameObject.GetComponent(SpriteRenderer).sprite == sabz)
ghermez = false;
if(hit.collider.transform.gameObject.GetComponent(SpriteRenderer).sprite != sabz)
ghermez = true;

Thanks

Thanks komodor.