RayCast won't filter out things?

For some reason, even if I specify that I don’t want the player model or the effects to be counted in the raycast, it still manages to hit the player. I’ve been debuging this for a bit and I can’t figure it out.

This script is located in game.StarterPlayer.StarterCharacterScripts

local HumanoidRootPart = script.Parent:WaitForChild("HumanoidRootPart")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local Character = player.Character or player.CharacterAdded:Wait()

local Torso = script.Parent:WaitForChild("Torso")

local parentBlackList = {Character, game.ReplicatedStorage.Resources} 


local Blacklist = {}

for i=1, 2, 1 do

	for _, items in pairs(parentBlackList[i]:GetDescendants()) do

		table.insert(Blacklist, items)
		print("Blacklisted: "..tostring(items.Name))
			
	end

end


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

while wait(0.1) do
	
	local result = workspace:Raycast(HumanoidRootPart.Position, (HumanoidRootPart.CFrame.LookVector) * 5)
	
	if result then
			
		HumanoidRootPart.Velocity = (HumanoidRootPart.CFrame.LookVector + Vector3.new(0,-3,0)) * -25
		print(result)
		
	end
	
end

You forgot to add the third argument, therefore the raycast is not influenced via RaycastParams.


This is not needed, as it will automatically filter out all desendants of an object which was specified above:

1 Like

Gosh I’m such an idiot, just one extra variable, thanks for helping. + note taken about the for loop! ^^

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