I am trying to make this script work, but it doesn't work as i expected, it's about egg hunt, and if i collect them all, then the GameController will be active

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EggsManager : MonoBehaviour
{
public GameObject eggs;
public GameManager _GameManager; // Assign this in the Inspector.
public GameObject GameController;

void Update()
{
    eggs = GameObject.FindGameObjectsWithTag("Egg");

    bool allEggsDestroyed = true;

    foreach (GameObject Egg in eggs)
    {
        if (Egg != null)
        {
            allEggsDestroyed = false;
            break;
        }
    }

    if (allEggsDestroyed)
    {
        GameObject GameController = GameObject.FindGameObjectWithTag("GameController");

        if (GameController != null)
        {
            GameController.SetActive(true);
            _GameManager = GetComponent<GameManager>();
            _GameManager.enabled = true;
        }
    }
}

}

Hi, can you explain what is the error you get ?

it’s alright, now I merged the script with other script, i just wanted to make an egg hunt level, to destroy enemies after i collect the eggs then key R, but now it works perfectly