help with obstacle and life system.

I'm trying to create a script to change the color of my character whenever it hits an obstacle and switches back the color after 2 secs. This script below seemes to be pretty buggy and sometimes life doesn't get affected even when the character hits an obstacle. Also, 2 or 3 lives gets reduced even if the character hits only one block. Any idea what is wrong with my scripts?

   function OnTriggerEnter (other : Collider)

        //hitting obstacle subtract life and changes color
        if(other.gameObject.tag == "obstacle")
            renderer.material.color =;
            //subtract life here
            HealthControl.LIVES -= 1;
            other.collider.renderer.material.color =;
            yield WaitForSeconds (2);
            renderer.material.color = Color.white;

The trigger may be calling out multiple collisions. Put in a bool that only alows it to trigger once in 2 seconds or so.

Wrap the whole thing in an if statement, test if your new bool is set. If not, set the bool to true, perform the function, wait 2 seconds, then set the bool back to false.