Physics2D.Raycast vector2.down not working

when trying to detect if im grounded or not i use the code

RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, 1f, layer);
        if(hit.collider != null) {
            isGround = true;
        }
        else {
            isGround = false;
        }

but it does not detect the ground and says its null everytime

As I noted here:

we KNOW this works, so back up.

Type in hard numbers (not transform.position) and hard layer masks.

This is fundamental Engineering 101: when something doesn’t work, remove stuff until you can get the barest minimum working. Start from the sample code in the docs… or perhaps a tutorial.