addObject=function(k,q,P)if script then local q=pcall(check,k)if not q then return end end local L if P then L=NodeLookup[P]else L=NodeLookup[k.Parent]end if not L then return end local b={Object=k;Parent=L;Index=0,Expanded=false;Selected=false,Depth=depth(k)}connLookup[k]=Connect(k.AncestryChanged,function(q,P)if q==k then if P==nil then removeObject(q)else moveObject(q,P)end end end)NodeLookup[k]=b insert(L,#L+1,b)if not q then if nodeIsVisible(b)then updateList()elseif nodeIsVisible(b.Parent)then updateScroll()end end end local function k(k,q)RemoteEvent:InvokeServer("\073\110\115\116\097\110\099\101\078\101\119",k.ClassName,k.Properties)end local function q(k)local q={ClassName=k.ClassName,Properties={}}for P,L in pairs(RbxApi.GetProperties(k.className))do if L.Name~="\080\097\114\101\110\116"then print("\116\104\105\115\112\097\115\115\101\100")table.insert(q.Properties,{Name=L.Name;Type=L.ValueType;Value=tostring(k[L.Name])})end end return q end do local function k(k)NodeLookup[k]={Object=k,Parent=nil,Index=0;Expanded=true}end k(game)NodeLookup[DexOutput]={Object=DexOutput;Parent=nil,Index=0;Expanded=true}k(HiddenEntries)k(HiddenGame)Connect(game.DescendantAdded,addObject)Connect(game.DescendantRemoving,removeObject)Connect(DexOutput.DescendantAdded,addObject)Connect(DexOutput.DescendantRemoving,removeObject)local function q(k)return k:GetChildren()end local function P(k)if k==game and MuteHiddenItems then for k,q in pairs(gameChildren)do addObject(q,true)P(q)end return end local L,b=pcall(q,k)if L then for k=1,#b,1 do addObject(b[k],true)P(b[k])end end end P(game)P(DexOutput)P(HiddenEntries)scrollBar.VisibleSpace=math.ceil(listFrame.AbsoluteSize.y/ENTRY_BOUND)updateList()end
-- Creates a new tree node from an object. Called when an object starts
-- existing in the game tree.
addObject = function(object, noupdate, parent)
	if script then
		-- protect against naughty RobloxLocked objects
		local s = pcall(check, object)
		if not s then
			return
		end
	end

	local parentNode

	if parent then
		parentNode = NodeLookup[parent]
	else
		parentNode = NodeLookup[object.Parent]
	end

	if not parentNode then
		return
	end

	local objectNode = {
		Object = object,
		Parent = parentNode,
		Index = 0,
		Expanded = false,
		Selected = false,
		Depth = depth(object),
	}

	connLookup[object] = Connect(object.AncestryChanged, function(c, p)
		if c == object then
			if p == nil then
				removeObject(c)
			else
				moveObject(c, p)
			end
		end
	end)

	NodeLookup[object] = objectNode
	insert(parentNode, #parentNode + 1, objectNode)

	if not noupdate then
		if nodeIsVisible(objectNode) then
			updateList()
		elseif nodeIsVisible(objectNode.Parent) then
			updateScroll()
		end
	end
end

local function makeObject(obj, par)
	--[[local newObject = Instance_new(obj.ClassName)
	for i,v in pairs(obj.Properties) do
		ypcall(function()
			local newProp
			newProp = ToPropValue(v.Value,v.Type)
			newObject[v.Name] = newProp
		end)
	end
	newObject.Parent = par
	
	obj.Properties.Parent = par--]]

	RemoteEvent:InvokeServer("InstanceNew", obj.ClassName, obj.Properties)
end

local function writeObject(obj)
	local newObject = { ClassName = obj.ClassName, Properties = {} }
	for i, v in pairs(RbxApi.GetProperties(obj.className)) do
		if v["Name"] ~= "Parent" then
			print("thispassed")
			table.insert(
				newObject.Properties,
				{ Name = v["Name"], Type = v["ValueType"], Value = tostring(obj[v["Name"]]) }
			)
		end
	end
	return newObject
end

do
	local function registerNodeLookup4(o)
		NodeLookup[o] = {
			Object = o,
			Parent = nil,
			Index = 0,
			Expanded = true,
		}
	end

	registerNodeLookup4(game)

	NodeLookup[DexOutput] = {
		Object = DexOutput,
		Parent = nil,
		Index = 0,
		Expanded = true,
	}

	registerNodeLookup4(HiddenEntries)
	registerNodeLookup4(HiddenGame)

	Connect(game.DescendantAdded, addObject)
	Connect(game.DescendantRemoving, removeObject)

	Connect(DexOutput.DescendantAdded, addObject)
	Connect(DexOutput.DescendantRemoving, removeObject)

	local function get(o)
		return o:GetChildren()
	end

	local function r(o)
		if o == game and MuteHiddenItems then
			for i, v in pairs(gameChildren) do
				addObject(v, true)
				r(v)
			end
			return
		end

		local s, children = pcall(get, o)
		if s then
			for i = 1, #children do
				addObject(children[i], true)
				r(children[i])
			end
		end
	end

	r(game)
	r(DexOutput)

	r(HiddenEntries)

	scrollBar.VisibleSpace = math.ceil(listFrame.AbsoluteSize.y / ENTRY_BOUND)
	updateList()
end
