local t={}do local function o(t)if t then local e=t:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if e then return t,e else return o(t.Parent)end end end t.FindCharacterAncestor=o local function e(t,N,r)r=r or{}local K,m,s,W=Workspace:FindPartOnRayWithIgnoreList(t,r)if K then if N and K.CanCollide==false then local m,s=o(K)if s==nil then table.insert(r,K)return e(t,N,r)end end return K,m,s,W end return nil,nil end t.Raycast=e end local o={}local function e(t)local e=t and t.Character if e then local N=o[t]if N and N.Parent==e then return N else o[t]=nil local N=e:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if N then o[t]=N end return N end end end

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
