local Z=newproxy()local e=newproxy()local t=game:GetService("\082\117\110\083\101\114\118\105\099\101")local function U(t,U)local J=typeof(t)if J=="\102\117\110\099\116\105\111\110"then return Z elseif J=="\116\104\114\101\097\100"then return e end if U then return U end if J=="\073\110\115\116\097\110\099\101"then return"\068\101\115\116\114\111\121"elseif J=="\082\066\088\083\099\114\105\112\116\067\111\110\110\101\099\116\105\111\110"then return"\068\105\115\099\111\110\110\101\099\116"elseif J=="\116\097\098\108\101"then if typeof(t.Destroy)=="\102\117\110\099\116\105\111\110"then return"\068\101\115\116\114\111\121"elseif typeof(t.Disconnect)=="\102\117\110\099\116\105\111\110"then return"\068\105\115\099\111\110\110\101\099\116"end end error("\070\097\105\108\101\100 \116\111 \103\101\116 \099\108\101\097\110\117\112 \102\117\110\099\116\105\111\110 \102\111\114 \111\098\106\101\099\116 "..(J..("\058 "..tostring(t))))end
-- Trove
-- Stephen Leitnick
-- October 16, 2021

local FN_MARKER = newproxy()
local THREAD_MARKER = newproxy()

local RunService = game:GetService("RunService")

local function GetObjectCleanupFunction(object, cleanupMethod)
	local t = typeof(object)
	if t == "function" then
		return FN_MARKER
	elseif t == "thread" then
		return THREAD_MARKER
	end
	if cleanupMethod then
		return cleanupMethod
	end
	if t == "Instance" then
		return "Destroy"
	elseif t == "RBXScriptConnection" then
		return "Disconnect"
	elseif t == "table" then
		if typeof(object.Destroy) == "function" then
			return "Destroy"
		elseif typeof(object.Disconnect) == "function" then
			return "Disconnect"
		end
	end
	error("Failed to get cleanup function for object " .. t .. ": " .. tostring(object))
end
