Mouse.TargetFilter, why just why?

So I want to use Mouse.TargetFilter, except uh, yeah you can only set it to a single Instance, so uh I need to set it to multiple Instances, so uh what can I do instead?

You should raycast from the mouse (use userInputService:GetMouseLocation for getting the mouse location, and workspace.CurrentCamera:ViewportPointToRay for getting the origin and direction), then using the RaycastParams, add the instances that need to be ignored.

The instances you want to filter can simply have the same parent/ancestor. EX:
You have a RedPart, GreenPart, BluePart and OrangePart at your disposal. You can pick any part and move rest of the parts under it such that they become descendants. That way mouse.TargetFilter will filter them all.

Yeah currently Im working with rigs, I need to filter out the HRP, and parenting it to something else is gonna cause some problems

OK cool, Ill try this out when I get on my PC :]

1 Like

Hmm it seems that it always returns nil, even when the params arent made to ignore anything, or just not included, so I take it I did something wrong when firing the raycast:

local MousePo = UIS:GetMouseLocation()
local ViewportRay = workspace.CurrentCamera:ViewportPointToRay(MousePo.X,MousePo.Y)
		
local params = SelectionParams(self.FilterType,self.FilterInstances)

local raycast = workspace:Raycast(ViewportRay.Origin,ViewportRay.Direction)

Oh yeah you gotta multiply the direction by some number. Also try using screenpointtoray because it’s less janky imo

1 Like

Yeah this works thanks! Since @7z99 recommend using the method, ima mark their message as the solution, thanks for your help though!

Nah it’s okay, I respect the wise decisions :+1:

1 Like

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