How to make mouse.hit or mouse.hit.p ignore players?

just what the title says i have everything figured out with my scripts just that sometimes the mouse clicks on other players or the local player itself and it doesnt aim/ throw where its supposed to, what can i do? i just need the mouse.hit.p to ignore player parts.

thanks to anyone that can help me with this

Theres a way to do it with Raycast but I don’t remember if you can with Mouse.

Either use mouse.TargetFilter or as @azqjanna suggested use raycast. you can create RaycastParams and use the properties FilterDescendantsInstances and FilterType to filter out instances.

TargetFilter can only contain one Instance so you have to do raycasting.
Also mouse is kind of depracated anyway.