local J={}local s=Instance.new("\070\111\108\100\101\114",game.ServerStorage)s.Name="\077\097\112\083\097\118\101"local p=game.Workspace:FindFirstChild("\077\097\112\080\117\114\103\101\080\114\111\111\102")if not p then p=Instance.new("\070\111\108\100\101\114",game.Workspace)p.Name="\077\097\112\080\117\114\103\101\080\114\111\111\102"end function J.SaveMap(J)for J,p in ipairs(game.Workspace:GetChildren())do if not p:IsA("\067\097\109\101\114\097")and(not p:IsA("\084\101\114\114\097\105\110")and not p:IsA("\070\111\108\100\101\114"))then local J=p:Clone()if J then J.Parent=s end end end end function J.ClearMap(J)for J,s in ipairs(game.Workspace:GetChildren())do if not s:IsA("\067\097\109\101\114\097")and(not s:IsA("\084\101\114\114\097\105\110")and not s:IsA("\070\111\108\100\101\114"))then s:Destroy()end end end function J.LoadMap(J)spawn(function()for J,s in ipairs(s:GetChildren())do local p=s:Clone()p.Parent=game.Workspace end end)end return J
local MapManager = {}

-- Local Variables
local MapSave = Instance.new('Folder', game.ServerStorage)
MapSave.Name = 'MapSave'

-- Initialization

local MapPurgeProof = game.Workspace:FindFirstChild('MapPurgeProof')
if not MapPurgeProof then
	MapPurgeProof = Instance.new('Folder', game.Workspace)
	MapPurgeProof.Name = 'MapPurgeProof'
end

-- Functions

function MapManager:SaveMap()
	for _, child in ipairs(game.Workspace:GetChildren()) do
		if not child:IsA('Camera') and not child:IsA('Terrain') and not child:IsA('Folder') then
			local copy = child:Clone()
			if copy then
				copy.Parent = MapSave
			end
		end
	end
end

function MapManager:ClearMap()
	for _, child in ipairs(game.Workspace:GetChildren()) do
		if not child:IsA('Camera') and not child:IsA('Terrain') and not child:IsA('Folder') then
			child:Destroy()
		end
	end
end

function MapManager:LoadMap()
	spawn(function()
		for _, child in ipairs(MapSave:GetChildren()) do
			local copy = child:Clone()
			copy.Parent = game.Workspace
		end
	end)
end
	
return MapManager
