Raycasting Filtering Not Working

Hello! I am encountering some problem where my raycasting script is not working. I have a collision group called “Hitbox” in which all of my custom player hitboxes are set to. (CollisionGroupId = 2)

When the raycast is fired it filters out the players own hitbox but leaves the rest. Yet when the raycast is fired at a hitbox it prints nil!

Here is the code:

local serverParam = RaycastParams.new()
serverParam.FilterDescendantsInstances = {workspace.Hitboxes:FindFirstChild(game.Players.LocalPlayer.Name)}
serverParam.FilterType = Enum.RaycastFilterType.Blacklist
serverParam.CollisionGroup = "Hitbox"
local serverCastResult = workspace:Raycast(origin, direction * self.settings.firing.distance, serverParam)
print(serverCastResult)
1 Like

Your making the Raycast ignore all hitboxes, including the one on the other character I assume. Why are you setting the CollisionGroup to Hitbox anyway if your already ignoring the Local player’s character anyway, just do this:

local serverParam = RaycastParams.new()
serverParam.FilterDescendantsInstances = {game.Players.LocalPlayer.Character}
serverParam.FilterType = Enum.RaycastFilterType.Blacklist

local serverCastResult = workspace:Raycast(origin, direction * self.settings.firing.distance, serverParam)
3 Likes