How do you refrence a bool in another script?

Basically i have a script to manage my UI and a script to manage collisions with objects that trigger parts of the UI. The UI manager is on its own empty game object called UImanager and the triggers script is on my player. Here are the scripts:

Triggers:

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

public class Triggers : MonoBehaviour
{
    GameObject UIManager;
    private void OnCollisionEnter(Collision hit)
    {
        if(hit.transform.tag == "Trigger0")
        {
            UIManager.Trigger0Triggered = true;
        }
    }
}

And here’s the one for my UIManager:

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

public class UIManager : MonoBehaviour
{
    public bool Trigger0Triggered;
    public GameObject Notes0;
    public GameObject Notebook;
    void Start()
    {
        Trigger0Triggered = false;
        Notebook.SetActive(false);
        Notes0.SetActive(false);
    }

    void Update()
    {
        if(Input.GetKey("p"))
        {
            Debug.Log("it works");
            Time.timeScale = 0;
            Notebook.SetActive(true);

            if (Trigger0Triggered)
            {
                Notes0.SetActive(true);
            }
        }
    }
}

I get an error saying: Assets\Scripts\Triggers.cs(12,23): error CS1061: ‘GameObject’ does not contain a definition for ‘Trigger0Triggered’ and no accessible extension method ‘Trigger0Triggered’ accepting a first argument of type ‘GameObject’ could be found (are you missing a using directive or an assembly reference?)
Any help would be greatly appreciated, thanks

You really need to get into C# events! Communicating between game objects is an important area and very common. If you don’t mind, I’m going to refer you to an earlier post of mine where I explained this for another user.

You have an ‘event’ of a trigger in your player script. Imagine that you also wanted to get audio to play, start an animation as well as update the UI. You don’t want to link all those separate classes so you sort of shout out “Hey Event xyz has just happened”. All those other managers listen out and react. That’s the principle of events and you can find the syntax and implementation in my code linked to above. That should enable you to sort this problem of yours.

By the way, you can sometimes get away with using a public static bool and that is visible to all classes but that’s considered bad practice. Can you guarantee that you’ll only ever want one of these bools? What happens when you turn the game into a multi-player? Might you then want several copies of the same bool? Don’t be tempted. Events are the way to go. Let me know how you get on…