material color aways changes

Hi atm i am using this script to chnage the color of a cube when it enters a trigger it also has a trigger on it but it is always red no matter what and it should be green when its not in the trigger
i am on windows xp and it wont sho wthe code button so youl have to deal with it :stuck_out_tongue:

using UnityEngine;
using System.Collections;

public class BlockBuild : MonoBehaviour
{
// Use this for initialization

void OnTriggerEnter2D (Collider2D col)
{
	if(col.tag == "Player") renderer.material.color =  Color.red;
}

}

If you change the color of the material it will stay that color until you change it again. Try to change it back after exiting the collision:

public class BlockBuild : MonoBehaviour 
{
  void OnTriggerEnter2D (Collider2D col)
    {
        if(col.tag == "Block") col.renderer.material.color =  Color.red;
 
    }

  void OnTriggerExit2D (Collider2D col)
    {
        if(col.tag == "Block") col.renderer.material.color =  Color.green;
 
    }
}