How to ignore part with mouse?

Hello there! So i am making a cool game and i need to add something. How could i ignore part Using Mouse.Hit?

Lemme explain:

so bob want to shoot somewhere in the house while the camera is on the top
but bob can’t because the mouse detect the roof insted of where he shoot

so i was wondering can we exclude part when we do mouse.Hit?

Mouse.TargetFilter = workspace.Part

This’ll filter out the part + any descendants.

1 Like

Use Mouse.TargetFilter and the hit detection will go through that part, meaning that part was ignored. Based on the image, I assume you’re also ray-casting, you can use WorldRoot:Raycast with a RaycastParams object. RaycastParams allows for filtering using FilterDescendantsInstances and can be set to it’s respective whitelist type with FilterType

Learn more about raycasting with RaycastParams here:
https://create.roblox.com/docs/reference/engine/classes/WorldRoot

thank you so much it worked ill sure use it!

Also thank you too i’m sure this will also be usefull oneday!

If you ever need to filter multiple instances while still using the legacy mouse object you can parent them all to a single folder instance and filter that instead.

Mouse.TargetFilter = Folder --Folder of instances to filter.