how do you change the color of a object

i am working onn a script to make a platform that vanishes and then comes back but i would like it to turn red when i touch it so you know it will vanish. can someone show me how to edit the color. i looked at the scripting reference and it kept giving me errors when i tried using that code.

this is my code

var obj : Transform;
function OnCollisionEnter () {
            var obj = Instantiate(obj, transform.position, Quaternion.identity);
			Destroy (gameObject ,1);
}

You can access a game object’s material and edit properties like colour through the Renderer class.

gameObject.renderer.material.color = Color.red;