map=mapContainer:FindFirstChild(MAP_NAME)local Q=map:Clone()function MapManager.loadMap()if map then print("\067\117\114\114\101\110\116 \109\097\112 \109\117\115\116 \098\101 \117\110\108\111\097\100\101\100 \098\101\102\111\114\101 \108\111\097\100\105\110\103 \097 \110\101\119 \109\097\112\046 \082\101\116\117\114\110\105\110\103 \099\117\114\114\101\110\116 \109\097\112\046")return map end map=Q:Clone()map.Parent=mapContainer map.Name=MAP_NAME return map end function MapManager.unloadMap()if map then map:Destroy()map=false end end function MapManager.reloadMap()if map then print("\082\101\109\111\118\105\110\103 \099\117\114\114\101\110\116 \109\097\112 \098\101\102\111\114\101 \114\101\108\111\097\100\105\110\103")map:Destroy()end map=Q:Clone()map.Parent=mapContainer map.Name=MAP_NAME return map end function MapManager.getMap()return map end function MapManager.getSpawnLocations()if map then return map:FindFirstChild("\083\112\097\119\110\076\111\099\097\116\105\111\110\115")end return false end return MapManager
-- Clone map upon game start. This is what will be loaded and unloaded
-- Destroy original after cloning
map = mapContainer:FindFirstChild(MAP_NAME)
local cachedMap = map:Clone()

function MapManager.loadMap()
	if map then
		print("Current map must be unloaded before loading a new map. Returning current map.")
		return map
	end

	map = cachedMap:Clone()
	map.Parent = mapContainer -- Parent it to the map container
	map.Name = MAP_NAME -- Rename the map so that we can use the unloadMap() function later to remove it.
	return map -- Return the map we selected, in case we want to display its info.
end

function MapManager.unloadMap()
	if map then
		map:Destroy()
		map = false -- Easier to handle than nil
	end
end

function MapManager.reloadMap()
	if map then
		print("Removing current map before reloading")
		map:Destroy()
	end

	map = cachedMap:Clone()
	map.Parent = mapContainer -- Parent it to the map container
	map.Name = MAP_NAME -- Rename the map so that we can use the unloadMap() function later to remove it.
	return map -- Return the map we selected, in case we want to display its info.
end

function MapManager.getMap()
	return map
end

function MapManager.getSpawnLocations()
	if map then
		return map:FindFirstChild("SpawnLocations")
	end

	return false
end

return MapManager
