How di i make the background color change smoothly

void Start ()
{
TimeStart = Time.time;
wait ();
}

IEnumerator wait()
{
	
	while(repeat == true)
	{
		yield return new WaitForSeconds (2f);
		int RDcolor = Random.Range (0, Allcolors.Length);
		// Changing the color
		yield return new WaitForSeconds (2f);
		GetComponent<Camera> ().backgroundColor = Color.Lerp (StartColor, RDcolor, Time.deltaTime);
		yield return new WaitForSeconds (2f);
		repeat = true;
	}

}

void Update ()
{
	StartCoroutine ("wait");
}

}

At start, the colors was changing rapidly, even with someone that has epilepsy would sturggle. I’m trying to change the background color smoothly between these random colors however it slightly changesthe intensity of the same color. I will need help on this. Thanks.

Good day.

First problem is this line only run one time.

     yield return new WaitForSeconds (2f);
     GetComponent<Camera> ().backgroundColor = Color.Lerp (StartColor, RDcolor, Time.deltaTime);

if you want to be a loop,try use WaitUntil

	yield return new WaitForSeconds (2f);
	int RDcolor = Random.Range (0, Allcolors.Length);

	// Changing the color
	
	float startTime=Time.time;
	float totalTime=2;
	var camera= GetComponent<Camera> ();
	yield return new WatUntil(()=>{
		camera.backgroundColor = Color.Lerp (StartColor, RDcolor, (Time.time-startTime)/totalTime);
		return Time.time>startTime+totalTime;
	});
	yield return new WaitForSeconds (2f);
	repeat = true;

Next, coroutine just need to start once,so you can’t put it in Update, but put in Start.
This is the reason why colors was changing rapidly.

 void Start () 
 {
     StartCoroutine ("wait");
 }