How to make a map saving system

I’ve been working on a minecraft game on roblox,


But i was trying to make it where you click a butto nto save your map,(The game server is 1 player per server)I have know idea how to make,if you have any suggestions post it here

4 Likes

Can you give more info on what you’ve tried? (or use the template)

1 Like

like in minecraft you press a button to save your map so you wont lose anything you built!

2 Likes

Since I this aint really the place to give scripts, Ill tell you how rather then giving you the script.

So basically if you want it like minecraft you will need to be able to go through all parts. Since you will need to be able to sort the parts from players, I’d recommend having a folder with each player’s stuff.

Once you have that, it will be just as simple as going through the parts and saving all of the information of each part.


local datastore  = game:GetService('DataStoreService'):GetDataStore("MapSave")
local FolderToSave = --Path to folder
local InfoToSave = {}

--Save
for i,v in pairs(FolderToSave:GetChildren()) do
      local PartInfo = {
      ["Name"] = v.Name;
      ["Size"] = v.Size;
      ["Position"] = v.Position
      }
     -- You can continue that pattern for the the rest of the properties you want to save. 
    table.insert(InfoToSave, PartInfo)
end
datastore:SetAsync(Player.UserId, InfoToSave)

This is a simple way to save the information of a part, to load it is is as simple as getting the information from the datastore and replicating the properties back


local good, info = pcall(function()
     return datastore:GetAsync(Player.UserId)
end)
if good then
     for i,v in pairs(info)
           local NewPart = Instance.new("Part", FolderToSave)
           NewPart.Name = v.Name
           NewPart.Size = v.Size
           NewPart.Position = v.Position
     end
end

Please note: this is just off the top of my head so there may be bugs inside. This should give you the basic idea of how it is done though!

19 Likes

The only way I could thing of doing this is make a Data store and store a value called “User/Map” with the value being a table. You would fill said table will every instance in work space and note down its Material,Position,Color, and other values. Then when they rejoin, you load that value and loop through the table again but this table create an instance for every item and set its properties to the ones defined.

1 Like

Store it in some sort of database and iterate through for important values(name,size,position). When you need it loaded, call a method that creates objects based on already supplied properties.

Hope you intend to serialise or compress that data, otherwise you’re going to end up with a DataStore that potentially exceeds the maximum count. Remember that this is a world saving system.

Left that out with intention. That should be common sense practice. Appreciate it though.