Why is this Function returnng false?

So I am trying to check if the player is on ground and i have this function set up:

    void Update()
    {
        onGround = IsOnGround();
    }

    bool IsOnGround()
    {
        bool retVal = false;
        Vector3 origin = transform.position + new Vector3(0f, 0.05f, 0f);
        RaycastHit hit;
        if(Physics.Raycast(origin, -Vector3.up, out hit, 0.5f, layerMask))
        {
            retVal = true;
        }
        return retVal;
    }

When was debugging why movement wasnt working i tried Debug.Log(onGround); and i got false. I just want to hear a quick answer because i think i made some stupid mistae again and will facepalm after the solution…

Ty
~Nik

If the raycast doesn’t hit any colliders, retVal is never set to true.

Maybe you never set the layerMask in your inspector?