Cross-script variable troubles [SOLVED]

I have a bool value hasKey[×] & I can’t get its value to change.
I’ve stared at this for hours and I’m entirely at a loss for what to do.

Control:

public class Control : MonoBehaviour
{
    [HideInInspector]
    public bool flashlight, flashdrive, disk, newHouse, xMas95, goldfinchVHS;
    [HideInInspector]
    public bool[] hasKey;
    [HideInInspector]
    public List<int> locked;

    protected virtual void Awake()
    {
        hasKey = new bool[30];
        locked = new List<int> { 0, 3, 8, 9, 10, 13, 14, 15, 16, 17, 18, 19, 20, 24, 25, 28, 29 };

        for (int i = 0; i < hasKey.Length; i++)
        {
            hasKey[i] = !locked.Contains(i);
        }
    }

    private void Start()
    {
        flashlight = false;
        flashdrive = false;
        disk = false;
        newHouse = false;
        xMas95 = false;
        goldfinchVHS = false;      
    }

    public bool CheckCollision(Collider obj)
    {
        RaycastHit hit;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit))
        {
            if (hit.transform == obj.transform)
            {
                return true;
            }
            else return false;
        }
        else return false;
    } 
}

GettingKey:

public class GettingKey : Control
{
    public static GettingKey key;
    Collider KeyColl;
    public int KeyNumber;

    public void Start()
    {
        KeyColl = gameObject.GetComponent<Collider>();
    }

    void Update()
    {
        if (Input.GetButton("Fire1"))
        {
            if (CheckCollision(KeyColl))
            {
                hasKey[KeyNumber] = true;
                gameObject.SetActive(false);
            }
        }
    }
}

DoorOpenCloseControl:

public class DoorOpenCloseControl : Control
{
    public static DoorOpenCloseControl control;
    Animator doorAnim;
    public int doorNumber;
    Collider doorColl;
    public AudioSource DoorLocked;
  

    void Start()
    {
        doorColl = gameObject.GetComponent<Collider>();
        doorAnim = gameObject.GetComponent<Animator>();
    }

    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            if (CheckCollision(doorColl))
            {
                if (hasKey[doorNumber]) //evaluates as its original setting even if I've changed the value in GettingKey
                {
                    doorAnim.SetBool("open", !doorAnim.GetBool("open"));
                }
                else
                {
                    DoorLocked.Play();
                }
            }
        }
    }
}

First I’d make sure you script is running that sets the bool to true. Second, what is keyNumber? Is it the index in the array that the “key” is in?

That part of the script seems to be working, as doors set as unlocked open without trouble.
And yes, keyNumber is the index of the key.

So what part does not appear to be working? When you pick up the key?

When you pick up the key, it still registers as you not having the key; basically I need a way to ensure that hasKey[KeyNumber] == hasKey[doorNumber], where KeyNumber and doorNumber are the same, if that makes sense.

GettingKey inherits from control and your doorscript inherits from control, but that’s probably not the way you want to do it. Either way, both these scripts maintain their own array of hasKey. You need to have a common hasKey array that they access. You should have the control script maintain a your array and the other two scripts access this array through a reference of some sort. Otherwise, you could make the array static I suppose. As it currently is, the door has no way of knowing that the key has been obtained as it’s own array doesn’t know the key has been picked up.

Setting the array to static worked, thank you!!