How to make mouse target to nearest target rather than it touching them?

I’m not sure if you have seen games where there’s a mouse that automatically locks on to its nearest target rather than having to fully make the mouse touch the target? Games like Iron Man Simulator 2 and War Machines have achieved this.

My confusion is that I don’t know how you can make it so the mouse can be within a distance to the nearest target, since mouse is a 2D property and I’ve tried mouse.Target, which doesn’t really help since you would need the mouse to actually touch the target rather than being near them within a certain distance given.

I would really appreciate it if anyone can provide me a solution for this as I’ve noticed this can be easily made.

2 Likes

I’d bind a GetPartBoundsInRadius to mouse when it moves and go from there.

WorldRoot | Documentation - Roblox Creator Hub

1 Like

How would radius work? Is it meant to be the 2D property of the mouse?

1 Like

Figured out a solution. Using mouse.hit.p simply works since you’re using its position to find the nearest target’s position.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.