2D Script and layer bug

Hello

So i created a collider script for my 2D project but whenever i play it just spills out “Value cannot be null” error
from boxCollider.OverlapCollider(filter, hits); this line. In addition for some reason my character isn’t colliding with anything that isn’t in the User Layer “Walls” exclusively.

[RequireComponent(typeof(BoxCollider2D))]
public class Collidable : MonoBehaviour
{
    public ContactFilter2D filter;
    private BoxCollider2D boxCollider;
    private Collider2D[] hits = new Collider2D[10];

    protected virtual void Start()
    {
        boxCollider = GetComponent<BoxCollider2D>();
    }
    protected virtual void Update()
    {
        boxCollider.OverlapCollider(filter, hits);
        for (int i = 0; i < hits.Length; i++)
        {
            if (hits[i] == null)
                continue;

            OnCollide(hits[i]);

            hits[i] = null;
        }
    }

    protected virtual void OnCollide(Collider2D coll)
    {
        Debug.Log(coll.name);
    }
}

Any help is appriciated, thanks in advance

This isn’t a 2D or physics thing. This is a basic scripting problem.

Always post the full error in all its glory rather than describing the error. The error should tell you everything you need to know to fix it. For instance, the error above is the description of an exception, likely an ArgumentNullException meaning the argument to something is NULL. It’ll tell you which line, column and which argument. From there it’s pretty much given you everything you need to investigate.