local X={"\080\097\114\116","\087\101\100\103\101\080\097\114\116";"\084\114\117\115\115\080\097\114\116","\077\111\100\101\108","\083\101\097\116","\086\101\104\105\099\108\101\083\101\097\116"}function isValidClass(G)local F=G.className for G=1,#X,1 do if F==X[G]then return true end end return false end function isValidPart(X)if isValidClass(X)==true then return X end return nil end function retriveParts(X)if isValidPart(X)and X.className~="\077\111\100\101\108"then WorkSpaceObjects[WSONum]=X WSONum=WSONum+1 else local G=X:GetChildren()for X=1,#G,1 do local F=isValidPart(G[X])if F~=nil then if F.className=="\077\111\100\101\108"then retriveParts(F)else if F.Anchored==false then WorkSpaceObjects[WSONum]=F WSONum=WSONum+1 end end end end end end function RemoveBits(X)if isValidPart(X)and X.className~="\077\111\100\101\108"then for G=1,#WorkSpaceObjects,1 do if X==WorkSpaceObjects[G]then table.remove(WorkSpaceObjects,G)WSONum=WSONum-1 end end else local G=X:GetChildren()for X=1,#G,1 do local F=G[X]if F.className=="\077\111\100\101\108"then RemoveBits(F)else for X=1,#WorkSpaceObjects,1 do if F==WorkSpaceObjects[X]then table.remove(WorkSpaceObjects,X)WSONum=WSONum-1 end end end end end end retriveParts(game.Workspace)game.Workspace.ChildAdded:connect(retriveParts)game.Workspace.ChildRemoved:connect(RemoveBits)
-- the following data is to update the ObjectTable
local ValidClassNames = { "Part", "WedgePart", "TrussPart", "Model", "Seat", "VehicleSeat" }
function isValidClass(part)
	local CN = part.className
	for i = 1, #ValidClassNames do
		if CN == ValidClassNames[i] then
			return true
		end
	end
	return false
end
function isValidPart(part) -- returns className if its a part or model otherwise returns nil
	if isValidClass(part) == true then
		return part
	end
	return nil -- not a part or an model
end

function retriveParts(model) -- main function for retriving all the parts of a model and loading them into a table
	if isValidPart(model) and model.className ~= "Model" then
		WorkSpaceObjects[WSONum] = model
		WSONum = WSONum + 1
	else
		local raw_model = model:GetChildren()
		for i = 1, #raw_model do
			local part = isValidPart(raw_model[i])
			if part ~= nil then
				if part.className == "Model" then
					retriveParts(part)
				else
					if part.Anchored == false then
						--if(part:findFirstChild("TAG") == nil) then
						--	Tag = Instance.new("ObjectValue")
						--	Tag.Parent = part
						--	Tag.Name = "TAG"
						WorkSpaceObjects[WSONum] = part
						WSONum = WSONum + 1
						--end
					end
				end
			end
		end
	end
end
function RemoveBits(model) -- Function for removing bits from our global table as they dont exist in the workspace anymore
	if isValidPart(model) and model.className ~= "Model" then
		for i = 1, #WorkSpaceObjects do
			if model == WorkSpaceObjects[i] then
				table.remove(WorkSpaceObjects, i)
				WSONum = WSONum - 1
			end
		end
	else
		local raw_model = model:GetChildren()
		for i = 1, #raw_model do
			local part = raw_model[i]
			if part.className == "Model" then
				RemoveBits(part)
			else
				for i = 1, #WorkSpaceObjects do
					if part == WorkSpaceObjects[i] then
						table.remove(WorkSpaceObjects, i)
						WSONum = WSONum - 1
					end
				end
			end
		end
	end
end

retriveParts(game.Workspace) -- call our retreiver
game.Workspace.ChildAdded:connect(retriveParts) -- just encase any new objects get added to the game
game.Workspace.ChildRemoved:connect(RemoveBits)
