raycast not detecting player

I’ve been working on a script where if the player is in sight of an enemy, they will shoot, but for some reason it never detects. what am I doing wrong? the capsule I’m using as a player is flagged as such

        currentdist = Vector3.Distance(transform.position, player.transform.position);
        RaycastHit hit;
        var rayDirection = player.transform.position - transform.position;
        positioning = new Vector3(this.transform.position.x, this.transform.position.y + 1, this.transform.position.z);
        if (currentdist < safedist && Physics.Raycast(positioning, rayDirection, out hit) && (hit.collider.tag == "Player"))
        {

                nav.destination = player.transform.position;
                Debug.DrawRay(transform.position, rayDirection * 1000, Color.red);
                Debug.Log("Seeyou!");
                shootatplayer();

        }
        else
        {

            Debug.DrawRay(transform.position, rayDirection * 1000, Color.white);
            nav.destination = points[destPoint].position;
            if (!nav.pathPending && nav.remainingDistance < 0.5f)
            {
                GoToNextPoint();
            }

        }

Never mind , I solved it by creating a layer mask and searching for every object other then player, so if it hit the player it would read nothing.currentdist = Vector3.Distance(transform.position, player.transform.position); RaycastHit hit; int layerMask = 1 << 8; layerMask = ~layerMask; var rayDirection = player.transform.position - transform.position; positioning = new Vector3(this.transform.position.x, this.transform.position.y + 1, this.transform.position.z); if (Physics.Raycast(positioning, rayDirection, currentdist, layerMask))