GameObject.Find returning NullReferenceException

Hi everyone! I’m trying to create a quiz game from the tutorial provided by Unity. I finished said tutorial and added many features on my own. Right now, I am trying to create an optional timed mode that becomes available when the player gets a perfect score on the game. So far, I have made a separate TimeLimit script that holds all the code that runs the timed mode. If that script is enabled, timed mode runs smoothly. However, I am trying to make that script (or the GameObject housing it) inactive until the player gets a perfect score. I am trying to accomplish this currently by using the script below, which returns a NullReferenceException:

 public void TimedMode()
    {
        GameObject.Find("TimeLimit").GetComponent<TimeLimit>().enabled = false;
    }

I have checked my spelling and tried to deactivate the overarching TimeLimit GameObject (as opposed to the script in it), but neither has changed anything. I also have checked to make sure my GameObject is not null, so that isn’t the problem either. The actual GameObject is in a separate scene from the one this script is in, but everything I’ve seen says GameObject.Find should search all scenes. If anyone has any ideas on how I can fix this problem (or if you need more info), please let me know! Thanks!

P.S. I should probably mention that my ultimate goal will be to start the script deactivated and then reactivate it with this script. Right now I am just trying to do the opposite so I can make sure it works and I understand it.

Easiest would be to make a public reference to the TimeLimit script and drag drop the script on it in the Inspector.

Much more efficient than GameObject.Find too.

Gamobject.find searches all active scenes.
It may be easiest to just make it so it is all on one scene.
Another thing you could do is start with the TimeLimit script active on another scene, only make the option to load the other scene once you have a perfect score.

to jojizaidi’s point,

in your time limit script add this to the top

    //public so anyone can access it, static so that it's always there, TimeLimit (or what ever the name of you script actually is), timing (you can put whatever you want for that really.
      public static TimeLimit timing;

then add this below it before your Start Method

 public void Awake()
{

    if (timing== null)
    {
       
        timing = this;
    }

    else if (timing!= this)
    {
        Destroy(gameObject);
    }
    DontDestroyOnLoad(gameObject);
 }

this will make the script follow you through every scene, now when you try to access it in another script it will look like this.

 TimeLimit.time.whatevertheboolyou'reaccess = false;

and you can access anything else you want too.

if the TimeLimit script is attached to an object thats running around your game (like, not an empty game Object) you might have to work some other magic.

Hey everyone! I was able to solve the problem by just making everything happen in a single scene so I could drag and drop into the inspector. Thanks for all the help!