Using bools for a triggered event? {SOLVED}

i want to use a boolean so that when i enter a trigger and the bool is false nothing will happen but when its true the event will be triggered, i want the bool to become true when a GUI button is clicked and I’m not sure how to do this.
also, i want the bool to be set to false at the start of my game, what code would i need to do this? sorry for asking a lot.

https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-button?playlist=17111

private bool myBool;

void Awake()
{
    myBool = false;
}

// this function goes into the button's onclicked event in it's inspector
public void ButtonClickedFunction()
{
    myBool = true;
}

public void OnTriggerEnter(Collider other)
{
    if(myBool)
    {
        //stuff
    }
}

things get a little more complicated when the boolean is not on the same script as the trigger code, you’ll need to have a reference to the gameobject/component the boolean is on (i.e. the gamemanager script).

thank you so much, you’re an absolute lifesaver, this all works, i tested it this time haha! :smile: