Since it only works for disabling the objects, I’m pretty sure that the FindGameObjectsWithTag() function only finds active GameObjects. Once you set them to false, it can’t find the objects to set them to active.
You could fix this by creating the array as a public variable, and setting the array to all the objects in the Start() function. That way, the array will only be set once, and then it has all the GameObjects stored, even after they’re disabled.
public GameObject[] gameObjectarray;
void Start()
{
gameobject array = Gameobject.FindGameObjectsWithTag("Level 2");
foreach(Gameobject go in gameobject array)
{
go.SetActive(false);
//Now you can enable them whenever you want
}
}
I would get around this by seting all of them active and in the start function find them and disable them. Then you can activate them when ever you want
You’d use the same array to loop through and activate them. If you deactivate them, you can’t use FindGameObjectsWithTag to find them again. You need to use the previous references to them you got before deactivating them.