function UTIL.FindCharacterAncestor(m)if m and m~=workspace then local M=m:FindFirstChild("\072\117\109\097\110\111\105\100")if M then return m,M else return UTIL.FindCharacterAncestor(m.Parent)end end return nil end UTIL.AssetURL="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061"UTIL.TouchEnabled=(game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")).TouchEnabled do local m,M=pcall(function()workspace.CurrentCamera:GetPanSpeed()end)UTIL.CanCheckPanSpeed=m end local m=game:GetService("\068\101\098\114\105\115")local M=0 function UTIL.Dprint(...)local C=""for m,M in pairs({...})do C=C..((C and" "or"")..tostring(M))end local r=Instance.new("\083\099\114\101\101\110\071\117\105")local e=Instance.new("\084\101\120\116\076\097\098\101\108")e.Text=C e.Size=UDim2.new(.25,0,.05,0)e.BackgroundTransparency=.5 e.Position=UDim2.new(0,0,0,M)e.TextWrapped=true e.Parent=r m:AddItem(r,30)r.Parent=script.Parent M=M<=600 and M+30 or 0 end WeldUtil={}do function WeldUtil.WeldBetween(m,M)local C=Instance.new("\087\101\108\100")C.Part0=m C.Part1=M C.C0=CFrame.new()C.C1=M.CFrame:inverse()*m.CFrame C.Parent=m return C end function WeldUtil.PermaWeld(M,m)local C=m.Parent m.Changed:Connect(function()delay(0,function()m.Parent=C end)end)end end local C={Listeners=nil}do UTIL.MakeClass(C)function C.Connect(M,m)if not M.Listeners then M.Listeners={}end table.insert(M.Listeners,m)end function C.Fire(m,...)if not m.Listeners then return end local M={...}for m,C in ipairs(m.Listeners)do spawn(function()C(unpack(M))end)end end end
-- Returns a character ancestor and its Humanoid, or nil
function UTIL.FindCharacterAncestor(subject)
	if subject and subject ~= workspace then
		local humanoid = subject:FindFirstChild("Humanoid")
		if humanoid then
			return subject, humanoid
		else
			return UTIL.FindCharacterAncestor(subject.Parent)
		end
	end
	return nil
end

UTIL.AssetURL = "http://www.roblox.com/asset/?id="

UTIL.TouchEnabled = game:GetService("UserInputService").TouchEnabled
do
	local suceeded, _ = pcall(function()
		workspace.CurrentCamera:GetPanSpeed()
	end)
	UTIL.CanCheckPanSpeed = suceeded
end

local DebrisService = game:GetService("Debris")
local DebugPrintOffset = 0
function UTIL.Dprint(...)
	local line = ""
	for _, segment in pairs({ ... }) do
		line = line .. (line and " " or "") .. tostring(segment)
	end
	local gui = Instance.new("ScreenGui")
	local label = Instance.new("TextLabel")
	label.Text = line
	label.Size = UDim2.new(0.25, 0, 0.05, 0)
	label.BackgroundTransparency = 0.5
	label.Position = UDim2.new(0, 0, 0, DebugPrintOffset)
	label.TextWrapped = true
	label.Parent = gui
	DebrisService:AddItem(gui, 30)
	gui.Parent = script.Parent
	DebugPrintOffset = (DebugPrintOffset <= 600) and DebugPrintOffset + 30 or 0
end

WeldUtil = {}

do
	function WeldUtil.WeldBetween(a, b)
		local weld = Instance.new("Weld")
		weld.Part0 = a
		weld.Part1 = b
		weld.C0 = CFrame.new()
		weld.C1 = b.CFrame:inverse() * a.CFrame

		weld.Parent = a
		return weld
	end

	function WeldUtil:PermaWeld(weld)
		local OriginalParent = weld.Parent
		weld.Changed:Connect(function()
			delay(0, function()
				weld.Parent = OriginalParent
			end)
		end)
	end
end

local InternalEvent = {
	Listeners = nil,
}
do
	UTIL.MakeClass(InternalEvent)
	function InternalEvent:Connect(func)
		if not self.Listeners then
			self.Listeners = {}
		end
		table.insert(self.Listeners, func)
	end
	function InternalEvent:Fire(...)
		if not self.Listeners then
			return
		end
		local args = { ... }
		for _, i in ipairs(self.Listeners) do
			spawn(function()
				i(unpack(args))
			end)
		end
	end
end
