local Q=require(script.Parent.Parent)local z=Q.Misc.GetCharacterFromPart function Raycast(Q,Y)Y=Y or{}local J,H,N,t repeat J,H,N=workspace:FindPartOnRayWithIgnoreList(Q,Y)t=z(J)if J and(not J.CanCollide and not t)then table.insert(Y,J)J=nil else return J,H,N end until J end return Raycast
--[[

The following represents a raycast function suitable for guns.

The ray passes through all CanCollide = false parts unless they belong to a Humanoid.

--]]

local Utils = require(script.Parent.Parent)

local FindCharacterAncestor = Utils.Misc.GetCharacterFromPart

function Raycast(lookRay, ignoreList)
	ignoreList = ignoreList or {}
	local target, point, normal, targetCharacter
	repeat
		target, point, normal = workspace:FindPartOnRayWithIgnoreList(lookRay, ignoreList)
		targetCharacter = FindCharacterAncestor(target)
		if target and not target.CanCollide and not targetCharacter then
			table.insert(ignoreList, target)
			target = nil
		else
			return target, point, normal
		end
	until target
end

return Raycast
