local c={}do local function X(c)if c then local o=c:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if o then return c,o else return X(c.Parent)end end end c.FindCharacterAncestor=X local function o(c,K,V)V=V or{}local R,g,l,H=Workspace:FindPartOnRayWithIgnoreList(c,V)if R then if K and R.CanCollide==false then local g,l=X(R)if l==nil then table.insert(V,R)return o(c,K,V)end end return R,g,l,H end return nil,nil end c.Raycast=o end local X={}local function o(c)local o=c and c.Character if o then local K=X[c]if K and K.Parent==o then return K else X[c]=nil local K=o:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if K then X[c]=K end return K end end end
--------------------------UTIL LIBRARY-------------------------------
local Utility = {}
do
	local function FindCharacterAncestor(part)
		if part then
			local humanoid = part:FindFirstChildOfClass("Humanoid")
			if humanoid then
				return part, humanoid
			else
				return FindCharacterAncestor(part.Parent)
			end
		end
	end
	Utility.FindCharacterAncestor = FindCharacterAncestor

	local function Raycast(ray, ignoreNonCollidable, ignoreList)
		ignoreList = ignoreList or {}
		local hitPart, hitPos, hitNorm, hitMat = Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
		if hitPart then
			if ignoreNonCollidable and hitPart.CanCollide == false then
				-- We always include character parts so a user can click on another character
				-- to walk to them.
				local _, humanoid = FindCharacterAncestor(hitPart)
				if humanoid == nil then
					table.insert(ignoreList, hitPart)
					return Raycast(ray, ignoreNonCollidable, ignoreList)
				end
			end
			return hitPart, hitPos, hitNorm, hitMat
		end
		return nil, nil
	end
	Utility.Raycast = Raycast
end

local humanoidCache = {}
local function findPlayerHumanoid(player)
	local character = player and player.Character
	if character then
		local resultHumanoid = humanoidCache[player]
		if resultHumanoid and resultHumanoid.Parent == character then
			return resultHumanoid
		else
			humanoidCache[player] = nil -- Bust Old Cache
			local humanoid = character:FindFirstChildOfClass("Humanoid")
			if humanoid then
				humanoidCache[player] = humanoid
			end
			return humanoid
		end
	end
end
