raycast returning null on ragdoll glitch

I have seen that people have these problems before but the solutions didnt quite work or the question was never answered.
My raycast Works normally on cubes, spheres and other shapes but when it hits a ragdoll it returns null. I can see that the debug rays are hitting accordingly but it keeps returning null.
this is the piece of the C# script:

void OnTriggerStay(Collider coll)
        int layerMask = 1 << 3;
        layerMask = ~layerMask;
        if (coll.tag == "HostileTroop" && hostile == false)
            possibleTargets[0] = coll.gameObject;
            RaycastHit hit;
            Vector3 raycastDir = possibleTargets[0].transform.position - transform.position;
            Debug.DrawRay(transform.position, raycastDir);
            if (Physics.Raycast(transform.position, raycastDir, out hit))
                if (hit.collider.tag == "HostileTroop" && hostile == false)
                    target = hit.transform.gameObject;

Does anyone Know the problem?
Thanks in advance…

EDIT: if the script acquiers a ragdoll as a possible target (which it can) it wint define it as the target and thus wont work.

i just happened to set it to the wrong layer…
never mind…