Raycasting "Ignore Arguement"

Why won’t my Raycast ignore the selected parts in the arguement which is a table? Does anyone have any solutions.
Here is the script: (Just the portion of the script you have to focus on, I already referenced everything)

Function = RunService.Heartbeat:Connect(function()
	-- CHECK PLATFORM BELOW:
	local RootPart = player.Character.LowerTorso

	local Ignore = {player.Character
		
	}
	
	for _, part in ipairs(workspace:GetDescendants()) do
		if part:IsA("BasePart") and part.Parent.Name == "Seats" then
			table.insert(Ignore, part)
		end
	end
	
	
	local ray = Ray.new(RootPart.CFrame.p,Vector3.new(0,-500,0))
	local Hit, Position, Normal, Material = workspace:FindPartOnRay(ray,Ignore)

If it is not possible for ignore to be a table, is there any other way I can do this?
Any help is appreciated. :grinning: Thanks much

(Srry for Bad English) :smiling_face_with_tear:

1 Like

not familiar with raycasting and tables, but i guess you could try adding a , next to player.character? sorry if this is not useful

With a quick look into the documentation we will see that the second parameter is an instance and not a table. You would have to do a workaround to fix this, but luckily we have the newer function WorldRoot:Raycast which has RaycastParams which does accept a table.

Here’s how you would apply that to your code:

local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude

Function = RunService.Heartbeat:Connect(function()
	local RootPart = player.Character.LowerTorso
	local Ignore = { player.Character }
	
	for _, part in workspace:GetDescendants() do
		if part:IsA("BasePart") and part.Parent.Name == "Seats" then
			table.insert(Ignore, part)
		end
	end

	raycastParams.FilterDescendantsInstances = Ignore

	local result = workspace:Raycast(RootPart.CFrame.p, Vector3.new(0, -500, 0), raycastParams)
	if not result then
		return --nothing below the character
	end

	local hit, position, normal, material = result.Instance, result.Position, result.Normal, result.Material
end)
4 Likes

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