function UTIL.FindCharacterAncestor(a)if a and a~=workspace then local G=a:FindFirstChild("\072\117\109\097\110\111\105\100")if G then return a,G else return UTIL.FindCharacterAncestor(a.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 a,G=pcall(function()workspace.CurrentCamera:GetPanSpeed()end)UTIL.CanCheckPanSpeed=a end local a=game:GetService("\068\101\098\114\105\115")local G=0 function UTIL.Dprint(...)local h=""for a,G in pairs({...})do h=h..((h and" "or"")..tostring(G))end local J=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=h e.Size=UDim2.new(.25,0,.05,0)e.BackgroundTransparency=.5 e.Position=UDim2.new(0,0,0,G)e.TextWrapped=true e.Parent=J a:AddItem(J,30)J.Parent=script.Parent G=G<=600 and G+30 or 0 end WeldUtil={}do function WeldUtil.WeldBetween(a,G)local h=Instance.new("\087\101\108\100")h.Part0=a h.Part1=G h.C0=CFrame.new()h.C1=G.CFrame:inverse()*a.CFrame h.Parent=a return h end function WeldUtil.PermaWeld(G,a)local h=a.Parent a.Changed:Connect(function()delay(0,function()a.Parent=h end)end)end end local h={Listeners=nil}do UTIL.MakeClass(h)function h.Connect(G,a)if not G.Listeners then G.Listeners={}end table.insert(G.Listeners,a)end function h.Fire(a,...)if not a.Listeners then return end local G={...}for a,h in ipairs(a.Listeners)do spawn(function()h(unpack(G))end)end end end

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
