Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is the UserInputService's Mouse.Hit?

So, uh, I wanted to bind a mouse to ignore multiple Instance's, but the plain ol' PlayerMouse can't do that (Or can it?). So, I'm trying to find a alternative to PlayerMouse in UserInputService but I can't find that. Thank you.

3 comments

0

The deprecated part is Mouse.KeyDown,not Mouse entirely, almost sure the only way to do that is by using Mouse.Hit

0

What about the part about "ignoring multiple Instances"?

1

mouse.TargetFilter may work, or by using Raycast

1 answer

This question is very well answered by the Mouse.TargetFilter page!

The property takes an Instance and blacklists it and its descendants when calculating Mouse.Hit or Mouse.Target, Mouse.Hit is a CFrame corresponding to the position and rotation of the mouse pointing at surfaces in the world. The documentation mentions the following:

This property is essentially a single-object blacklist for mouse raycasting. For more in-depth control on raycasting, see the following functions of Workspace:FindPartOnRay, FindPartOnRayWithWhitelist and FindPartOnRayWithIgnoreList.

Here I'd like to say use raycasting if you can, it sits well in the situation and generally gives you more control over filters and more information to work with. The setback here can be you're not provided with a CFrame but a position, though that's usually all you need.


Regardless, I'll mention the way to blacklist multiple instances with Mouse.TargetFilter. As said on the aforementioned page:

The descendants of the object are also ignored, so it is possible to ignore multiple objects so long as they are a descendant of the object to which this property is set.

You can hence set the TargetFilter to a folder containing the instances you wish to ignore.

This discussion is preserved as it was. New answers, comments, and votes are closed.