How can I make my players change colors when they collide?

The game is a war between two players who are spheres, and when they collide with each other, I want them to change to red and then fade back to their original color.
I’ve used this code for my walls to change colors:
using UnityEngine;
using System.Collections;

public class ColorChan : MonoBehaviour
{

bool toYellow, toRed;
float lerpValue, lerpDuration;

void Start()
{
    toYellow = false;
    toRed = false;
    lerpValue = 0f;
    lerpDuration = 1f;
}

void Update()
{
    if (toRed)
    {
        //change color to red
        gameObject.GetComponent<Renderer>().material.color = Color.red;
        toRed = false;
    }
    else if (toYellow)
    {
        // fade color to green
        if (lerpValue < 1)
        {

            lerpValue += Time.deltaTime / lerpDuration;
            gameObject.GetComponent<Renderer>().material.color = Color.Lerp(Color.red, Color.yellow, lerpValue);
        }
        else
        {
            toYellow = false;
            lerpValue = 0f;
        }

    }

}

void OnCollisionStay()
{
    toRed = true;
}

void OnCollisionExit()
{
    toYellow = true;
}

}
but when I applied it to my players I noticed that because of the plane they are on, the color stays the changed color, please help me understand how to if I can apply this to my players only when they collide with each other.

You can use OnTriggerEnter every time player touches some object color it’s changing to red then affter few sec it’s back to normal color :smiley:

OnTriggerEnter(Collider other)
{
if(other.gameObject.tag == “Enemy”)
{
GetComponent().color = Color.red;
StartCorutine(“FadeBack”);
}
}
void FadeBack()
{
yeild return new WaitForSeconds(1);
GetComponent().color = Color.black;
}