Disable any objects through 1 script

Hi I made clones of a ghost around my map and they flicker over time but I want it so after 11-15 flickers that the ghost will disappear and it randomly picks a clone and enables that instead

			GameObject ScaryFemale = GameObject.Find("ScaryFemale");
			GameObject ScaryFemale1 = GameObject.Find("ScaryFemale1");
			GameObject ScaryFemale2 = GameObject.Find("ScaryFemale2");
		}

	while (ScareSel <= 1){
			if(invisloop <= 11) {
				Debug.Log (invisloop);
			if (gameObject.renderer.enabled) {
				curTime = Random.Range(0.01f, maxTimeInvis);
			} else {
				curTime = Random.Range(0.01f, maxTimeVis);
				invisloop++;
			}
			gameObject.renderer.enabled = !gameObject.renderer.enabled;
			yield return new WaitForSeconds(curTime);
			}

There are 3 objects so how do I get the GameObject “ScaryFemale” in this code instead of the gameObject.renderer.enabled?

I had this working as 4 scripts by placing 3 on the character and having 1 control which script was running but it really wasn’t that feasible

As we can see from your snippet, it seems that the three GameObjects are inside some brackets, making them valid only inside those brackets. You should instead put them either outside any method and make them public, so you can access them from everywhere, or declare them outside those brackets (I don’t know if there is this possibility, your snippet doesn’t include much).

public class Script : MonoBehaviour
{
    // I've delcared them outside any method. I can now access them from anywhere in this class.
       GameObject ScaryFemale;
       GameObject ScaryFemale2;
       void Start()
       {
           // Let's fill in the objects when the game starts
           ScaryFemale = GameObject.Find("ScaryFemale");
           ScaryFemale2 = GameObject.Find("ScaryFemale2");
       }
    
       void Update()
       {
          //I Can now access both scaryfemales from here
          ScaryFemale.transform.position = Vector3.zero;
          ScaryFemale2.renderer.enabled = false;
       }
}

(This code is just a sort of pseudo-code, you should not be copying this, instead look at what I meant and try to implement it in your own script :))