FindGameObjectsWithTag returning false positives

I’ve been working on a simple construction for my system. Below I have the script that’s supposed to delete any game objects with a specific tag however it never seems to return null even when no game objects with that tag exist.

Documentation on FindGameObjectsWithTag

function Instantiate_Ghost(building_type:GameObject)
{
	var OtherGhosts : GameObject[] = GameObject.FindGameObjectsWithTag("Building_ghost");
			
			
	if (OtherGhosts != null) //check to see if there are other construction ghosts
	{
		print("OtherGhosts != null");
		for (var ghost in OtherGhosts)//Cycle through each other ghost and delete it.
		{
			print("We're destroying a ghost");
			Destroy(ghost);  //delete the ghost
			OtherGhosts = null;
		}
	}
	else  //OtherGhosts == null
	{
		print("We're making a ghost object");
		Instantiate (building_type, Vector3(0, 0, 0), Quaternion.identity);
	}
}

And it never will… just change your if statement…

if (OtherGhosts != null OtherGhosts.Count > 0) …

if the first condition fails, it wont get to the second condition, so you dont have to worry about it being null and trying to get the count

Sorry, JamesLeeNZ. I forgot to post my thank you, I think I understand why it was never returning null. So long as there’s a game object in the scene the array is made but it’s length is zero until it finds a game object with the tag it’s looking for.