Mouse TargetFilter not working with tables?

I was attempting to make a placement system thing, and I ended up making this as a test but it errored stating that I can’t use tables for TargetFilter. I looked into the API and this does seem to be the case so is there any way I can make it filter out a table instead of just an instance since I don’t want to mess around with my game hierarchy that much.

(simplified the code so you don’t have to look at a bunch of unrelated nonsense)

local mouse = game.Players.LocalPlayer:GetMouse()

local chr = game.Players.LocalPlayer.Character

local camera = workspace.CurrentCamera

mouse.TargetFilter = {

workspace.Dummy,

chr

} -- this i want to use with a table not a model or folder

while game:GetService("RunService").Heartbeat:Wait() do

workspace.Dummy:SetPrimaryPartCFrame(CFrame.new(mouse.Hit.p))

end
1 Like

Yeah its known problem, instead use raycast from camera or mouse
Raycast supports Filtering with tables

1 Like

Hey, I have for you great module from @EmeraldSlash .

Link: GitHub - EmeraldSlash/RbxMouse: A mouse library providing a consistent and simple interface to Roblox APIs.

4 Likes

I already looked into this one but the issue with it is that it uses Vector2 when I want it to raycast within the 3d space not the 2d space.

I was using it for exact thing you want to use it for and it worked perfectly.

I’ll try again since I kinda just took a guess at the module when I tried it first off

The Vector2 is there to choose which position from the screen you want to raycast from e.g. if you want to pretend the mouse is in a different position than it actually is. By default it chooses the mouse’s position, which is what you want. After it has a 2D position on the screen to cast from, RbxMouse converts it to a ray in the 3D world.

But you don’t need to think of any of this - with version 4 of the module the code to do what you want is literally just:

local raycastResult = RbxMouse:GetTargetIgnore({workspace.Dummy, chr})
1 Like