Hey! I need help with my Raycast filter not filtering correct.
I have tried a lot of different things but can’t really get my head around it as I am kinda new to Raycasts.
So I want my Raycast not to detect player characters but it’s currently not working, here is the code:
local unitRay = workspace.CurrentCamera:ScreenPointToRay(mouse.X, mouse.Y, 0)
local players = game:GetService("Players")
local Blacklist = {}
for i,v in pairs(players:GetChildren()) do
local character = v.Character
table.insert(Blacklist, character)
for e,f in pairs(character:GetChildren()) do
if f:IsA("BasePart") then
table.insert(Blacklist, f)
end
end
end
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = Blacklist
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local ray = Ray.new(unitRay.Origin, unitRay.Direction * 1000, raycastParams)
local hit, pos, normal = game:GetService("Workspace"):FindPartOnRay(ray, PickedObject)