I already made a couple maps, and I put them into a Folder called Maps, which is in ReplicatedStorage. Apparently the script that handles the map is in game.ServerScriptService.MainGameScript.GameManager.MapManager. Here's the code of that script:
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
I don't really see how the function SaveMap is that useful, since I'm going to be alternating maps. I just don't know what I should do, or if the answer is super obvious and I'm just not getting it.
