Map & Terrain (Save/Load) System

This system I made allows you to save and restore the game map and more.

You can save using this code while editing in studio, so you can save multiple maps and use them in the game.

local ServerStorage = game:GetService("ServerStorage")
local MapConfigModule = require(game:GetService("ServerScriptService").MapConfigModule)

local Map = MapConfigModule:SaveMap()

Map.Name = "Map1"
Map.Parent = ServerStorage.Maps

Use this to load a saved map:

local SavedGameArea:Folder = ServerStorage.Maps:FindFirstChild("GameArea")

function LoadGameArea()

	MapConfigModule:ClearAndRestart()
	--[[
	  If the map will be loaded only once (no reloading), you do not need to use the ClearAndRestart() function.
      but here we use it because the map can be loaded over and over again.
	--]]

	MapConfigModule:LoadMap(SavedGameArea)
end

script.Parent.TriggerEnded:Connect(function()
	LoadGameArea()
end)

when the map is loaded we need to reload the players’ characters.
We can do this with this code:

local Players = game:GetService("Players")
local MapConfigModule = require(script.Parent.MapConfigModule)

--reloads players' characters after the map is loaded

MapConfigModule.MapLoaded:Connect(function()
	for _,Player in Players:GetPlayers() do
		Player:LoadCharacter()
	end
end)

Some settings you can make from the settings script:
image

	Load_Lighting = true,
	Load_Workspace = true,
	Load_Terrain = true,
	
	Load_Lighting_Property = true,
	Load_Workspace_Property = true,
	Load_Terrain_Property = true,
	
	Load_Terrain_Material_Colors = true,

Open Source
Map save - Roblox

1 Like