How to detect headshoots?

I am making guns in minecraft and i kndont ow how to make detecting headshots and bodyshots. I have just this: positioned ~-0.99 ~-0.99 ~-0.99 if entity @s[dx=0] . I tried with dy but didnt work

Continue to help post