Random wait times

I have a basic script that makes my character flicker and then randomly disappears and actives a clone somewhere else

Problem is I don’t want the characters to constantly be active for the same time or have to manually set the time up 20+ times… I want it to spontaneously disappear and activate + this will come in handy in the future, I can’t for the life of me work out how to get “Random();” to work with “WaitForSeconds” here is a snap of my code and all the help is appreciated :slight_smile:

using UnityEngine;
using System.Collections;

public class InvisibleFlick : MonoBehaviour {
		public bool Active;

	Random r = new Random();
	int n = r.Next();

	IEnumerator Start () {


		gameObject.renderer.enabled = true;
		yield return new WaitForSeconds(3.00f);
		gameObject.renderer.enabled = false;
		yield return new WaitForSeconds(0.05f);
		gameObject.renderer.enabled = true;
		yield return new WaitForSeconds(4.0f);

If you want to simplify a code in Start (), probably so:

 public bool Active = true;

 IEnumerator Start () {
  float maxTimeVis = 5.0f; //max time for visible
  float maxTimeInvis = 0.05f; //max time for invisible
  float curTime = 0.0f;
  while(Active) {
   if (gameObject.renderer.enabled) {
    curTime = Random.Range(0.01f, maxTimeInvis);
   } else {
    curTime = Random.Range(0.01f, maxTimeVis);
   gameObject.renderer.enabled = !gameObject.renderer.enabled;
   yield return new WaitForSeconds(curTime);

I hope that it will help you.