help how do I get a bool to access 2 scripts

help I have a public bool but it doesn’t access the other script

here’s the script

{
	public bool egeg = false;
	void OnTriggerStay () 
	{
		if(egeg == false)
			egeg = true;
	}
}

and the other one

	public Transform Target1;
	public Rigidbody CubePrefab;
	void Update () 
	{
			if(egeg == true)
			InvokeRepeating("goo", 1 , 1);
	}
		void goo ()
		{
		Rigidbody cubefire;
		cubefire = Instantiate(CubePrefab) as Rigidbody;
		cubefire.AddForce(Target1.forward * 10);
	}
}

on your 2nd script you have to referenc your boolean first depending on the gameObject where the script is, it will be something like this:

2nd script:

 public Transform Target1;

    public Rigidbody CubePrefab;

    void Update () 
    {
            if( GameObject.Find("MyGameObject").GetComponent(FirstScript).egeg == true)
            {
                     InvokeRepeating("goo", 1 , 1);
            }
    }

        void goo ()
        {
             Rigidbody cubefire;
            cubefire = Instantiate(CubePrefab) as Rigidbody;
            cubefire.AddForce(Target1.forward * 10);

        }

So this should be working but of course, if you plan to use it in an update, try to reference your script first for better performances

for me it didn’t work and It came up with errors?

any thing else

I answered in another thread. Please make sure you don’t create duplicate …