Aimbot Is Not Very Precise At Selecting A Target

Hello, I am working on an aimbot script for my game and I was wondering what kind of method I could use to find the target.

Right now I am using whatever player is closest to mouse.Hit.p. But this method isn’t working as good as I imagined.

Right now, all I have implemented is ESP and wallcheck.

What method could I use to find a target more precisely? The centeral problem is when I am looking closer to another player, it locks onto the one farther some times.