My raycast can detect my players torso which it is facing, but when I insert my player’s character into the RaycastParams filter, no objects behind it are detected.
Code:
local blacklistModels = {camera.Parent.Parent}
for _,player in ipairs(game.Players:GetPlayers()) do
local chr = player.Character
table.insert(blacklistModels, chr)
end
print(blacklistModels)
print("We got a list of everything we want to blacklist in this raycast, including player characters")
-- Build a "RaycastParams" object
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = blacklistModels
raycastParams.IgnoreWater = true
print("The ray is being cast")
-- Cast the ray
local raycastResult = workspace:Raycast(camera.Position, camera.CFrame.lookVector * 9, raycastParams)
-- Interpret the result
if raycastResult then
print(raycastResult)
print("We found something!")
print("Object/terrain hit:", raycastResult.Instance:GetFullName())
print("Hit position:", raycastResult.Position)
print("Surface normal at the point of intersection:", raycastResult.Normal)
print("Material hit:", raycastResult.Material.Name)
end