I've been getting this error and I can't figure out why

I’ve been getting this error and I can’t figure out why

UnassignedReferenceException: The variable interactables of InteractDetect has not been assigned.
You probably need to assign the interactables variable of the InteractDetect script in the inspector.

using UnityEngine;

public class InteractDetect : MonoBehaviour
    Transform player;

    Collider[] interactables = new Collider[3];

    Vector3 colDist1;
    Vector3 colDist2;

    private void FixedUpdate()
        Physics.OverlapSphereNonAlloc(player.position, 2.0f, interactables, LayerMask.1 << 6);

        if (interactables[0] != null && interactables[1] != null)
            for (int i = 0; i < interactables.Length; i++)
                colDist1 = interactables[i].transform.position - player.transform.position;
                colDist2 = interactables[i+1].transform.position - player.transform.position;

                if (colDist1.sqrMagnitude > colDist2.sqrMagnitude)
                    Collider temp = interactables[i];
                    interactables[i] = interactables[i+1];
                    interactables[i+1] = temp;

Length of interectables array is 3… you checking for null only in [0] and [1]… so probably [2] is null and that throws an exception.

Furthermore you had for loop call, till:
i < interectables.lenght
and then checking in [i+1] so you will go beyond array lenght… for loop should be till:
i < interectables.lenght- 1

Try this fixes and check out.

Hope will do!