Raycast rarely damages player/npc

print('d')

local dmg

	local e = RaycastParams.new()

	if headshot == true then
		dmg = origDmg * 2
	else
		dmg = origDmg
	end



	for i,v in pairs(workspace:GetDescendants()) do
	if v:FindFirstAncestorOfClass('Model') and v:FindFirstAncestorOfClass('Model'):FindFirstChildOfClass('Humanoid') then
	local _table = {}
	local t = 1
	t = t + 1
	table.insert(_table,1,plr.Character)
	table.insert(_table,t,v)
	e.FilterDescendantsInstances = _table
	end
	end

	e.FilterType = Enum.RaycastFilterType.Blacklist
	e.IgnoreWater = false
	local rayDirection = origPos - pos * 500
	local raycastResult = workspace:Raycast(origPos, rayDirection, e)

	if raycastResult then
print('e')
		local hitPart = raycastResult.Instance


if hitPart and hitPart:FindFirstAncestorOfClass('Model') then		
local hitParent = hitPart:FindFirstAncestorOfClass('Model')

print('f')

print(hitParent.Name)

local hum = hitParent:FindFirstChild('Humanoid')

if hum then
		local dmgUI = game.ReplicatedStorage.DMG_UI:Clone()
		dmgUI.Parent = hitParent:FindFirstChild('Head')
		dmgUI.dmg.Text = '<b>-'..dmg..'</b>'
		hum.Health = hum.Health - dmg
end
end
	
	end
end)

What happens: https://streamable.com/8d2upy

Can you please explain exactly what you are trying to do in this entire block of code?

I’m starting to get [REDACTED] because of people NOT FORMATTING THEIR CODE. (Even though Roblox added this feature.) And it’s quite obvious this is not the whole script.

But, what I suppose is that the Raycast is hitting something very next to it’s origin. I’m not sure if filtering descendants make it so Raycasts can’t hit the filtered 3D Rendered Instances, but I rather suppose that it just makes it so the filtered descendants, even if hit, are ignored.