addObject=function(b,w,H)if script then local w=pcall(check,b)if not w then return end end local V if H then V=NodeLookup[H]else V=NodeLookup[b.Parent]end if not V then return end local P={Object=b;Parent=V;Index=0;Expanded=false,Selected=false,Depth=depth(b)}connLookup[b]=Connect(b.AncestryChanged,function(w,H)if w==b then if H==nil then removeObject(w)else moveObject(w,H)end end end)NodeLookup[b]=P insert(V,#V+1,P)if not w then if nodeIsVisible(P)then updateList()elseif nodeIsVisible(P.Parent)then updateScroll()end end end local function b(b,w)RemoteEvent:InvokeServer("\073\110\115\116\097\110\099\101\078\101\119",b.ClassName,b.Properties)end local function w(b)local w={ClassName=b.ClassName,Properties={}}for H,V in pairs(RbxApi.GetProperties(b.className))do if V.Name~="\080\097\114\101\110\116"then print("\116\104\105\115\112\097\115\115\101\100")table.insert(w.Properties,{Name=V.Name,Type=V.ValueType;Value=tostring(b[V.Name])})end end return w end do local function b(b)NodeLookup[b]={Object=b,Parent=nil;Index=0;Expanded=true}end b(game)NodeLookup[DexOutput]={Object=DexOutput,Parent=nil,Index=0;Expanded=true}b(HiddenEntries)b(HiddenGame)Connect(game.DescendantAdded,addObject)Connect(game.DescendantRemoving,removeObject)Connect(DexOutput.DescendantAdded,addObject)Connect(DexOutput.DescendantRemoving,removeObject)local function w(b)return b:GetChildren()end local function H(b)if b==game and MuteHiddenItems then for b,w in pairs(gameChildren)do addObject(w,true)H(w)end return end local V,P=pcall(w,b)if V then for b=1,#P,1 do addObject(P[b],true)H(P[b])end end end H(game)H(DexOutput)H(HiddenEntries)scrollBar.VisibleSpace=math.ceil(listFrame.AbsoluteSize.y/ENTRY_BOUND)updateList()end

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
