Raycast params different from Spherecast Params?

I have a script and when i begun the script i was using raycast but halfway through i switched to spherecast, I kept the same params because i didnt really think it would affect anything but now it just hits the players character everytime.

Any way to fix this??

local direction = (Target.Position - HumRoot.Position).Unit

local raycastParams = RaycastParams.new()

for i, part in pairs(char:GetDescendants()) do
		if part:IsA("BasePart") then
		raycastParams.FilterDescendantsInstances = {part}
	end
end
raycastParams.FilterType = Enum.RaycastFilterType.Exclude

local raycast = workspace:Shapecast(shield.PrimaryPart, direction * 50, raycastParams)
if raycast then
	print(raycast.Instance)
end
			

This is a weird way of filtering instances, you will end up over writing it with an array with only 1 part of the character inside it.

You should be able to just do this

		raycastParams.FilterDescendantsInstances = {char}
1 Like

that was the issue, dont know what i was thinking

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