Mouse.hit ignore parts

I want mouse.hit.p to ignore certain parts in folder that is in workspace.

There are some invisible parts in my game that should not affect mouse.hit.p.

I tried using Mouse.TargetFilter but it works only with single-object.

I use mouse.hit.p like this: Event:FireServer(mouse.hit.p).

8 Likes

Why don’t you make a script to filter out all the children in the folder?

1 Like

Set the TargetFilter to the folder

1 Like

Oh never mind, all you have to do is group all the parts you want to filter and use to make a model and using mouse.targetfilter on the model should work.

1 Like

You can use TargetFilter to filter objects from the mouse. Just say:

local Mouse = game.Players.LocalPlayer:GetMouse()
local folderToFilter = workspace:WaitForChild("FolderToFilter") 
Mouse.TargetFilter = folderToFilter

The mouse will not detect any objects if they are in the folder. You can also use a model for this if you prefer as it doesn’t matter as long as every object you want to filter/ignore is in that model/folder. This is actually exactly what I do with my placement module v3. I filter the folder where all the models are stored on the players plot so it’s easy to place down objects. Hope this helps!

21 Likes

But what if you have an element that you cannot place in a folder - such as terrain, or water ?

I don’t think that is possible, Though I don’t see that it would be that much of an issue as there isn’t much use case for that other than water.

I’ve never tested it but if it does hit the water you could fire a raycast if the the mouse is over terrain water.

non hum part
This is what I am trying to avoid. When I shoot a gun, I want the bullet to completely ignore stuff like terrain.

What happens if you put the “Terrain” instance in your TargetFilter?

If you need that functionality, you should make a custom system that uses raycasts.

1 Like

What if i want 1 more than 1 folder to be filtered? (I’m sorry for waking you up from your 2 years of slumber.)