Collection quest trouble. JavaScript

Hey guys and girls

Just asking a question in regards to a sort of quest system in JavaScript
I Currently have two objects
Sphere 1 and Sphere 2
these two spheres both have colliders around them as shown below,
I want the player to walk through both colliders
then set both the spheres to SetActive = false
easy enough, but then I want it too check when the player walks into a collider if the other object is false, so if I walk into sphere 1 then check to see if sphere 2 is SetActive = false
if the sphere reads as false, turn on another collider(not shown in the image)

this is what I am currently using, two scripts, one on each collider around Sphere1 and Sphere2

var collider1 : GameObject;
var Sphere1 : GameObject;

function OnTriggerEnter () 
{
Sphere1.SetActive (false);

	if(GameObject.FindWithTag("Sphere2").SetActive == false)
	{
		collider1.SetActive (true);
		}
}


var collider1 : GameObject;
var Sphere2 : GameObject;

function OnTriggerEnter () 
{
Sphere2.SetActive (false);

	if(GameObject.FindWithTag("Sphere1").SetActive == false)
	{
		collider1.SetActive (true);
		}
}

not sure where I am going wrong but any help would be greatly appreciated

thanks!

You need to check if the game object is active or not using GameObject.activeInHierarchy.

So your if condition becomes:

if(GameObject.FindWithTag("Sphere2").activeInHierarchy == false)

and same for another game object.

But since if the game object is inactive then GameObject.FindWithTag will not be able to find it anyways. You need to cache a reference to the required game object beforehand.

For this your script becomes:

Script on Collider 1:

var collider1 : GameObject;
var Sphere1 : GameObject;
var Sphere2 : GameObject;

function Start()
{
    // You can use this or you can assign it directly in inspector. You should assign it in inspector if this game object is going to be inactive at start.
    Sphere2 = GameObject.FindWithTag("Sphere");
}

function OnTriggerEnter () 
{
Sphere1.SetActive (false);
 
    if(Sphere2.activeInHierarchy == false)
    {
        collider1.SetActive (true);
        }
}

Similarly you need to do for second colllider.