Managing Data Stores for different Saves

Hey everyone!

I’m working on a Sand Box & Multi-Places Projects.

I will need to save a lot of things.

In my game, people will have two “inventories”.
In the first one, there will be the objects the player has and can place on his plot.
And on the second one, there will be “materials” and this kind of things.

I want to get the second inventory and all the values and currencies when the player loads.

And I want to load the ploat and the position of each objects later seperatly.

So I’m wondering if I save everything inside the same DataStore or if I create a dedicated DataStore for the placed objects.

What do you think about it?
Ask question if you want!

Thanks.

image

I thought about something like this:
The Global Save for the currencies, the two “Inventories” and for other things to save.
And the Sand Box Save for all the placed Items and for the upgrade of the plots like “size of plots”

What do you think about doing something like this?

And using these functions to save & load from a ModuleScript:
image

You could use a dedicated datastore. Even though you will have to make more datastore calls, you would be able to store bigger plots since datastores have a size limit. It really depends on how you serialize the information

1 Like

And how should I serialize the information? I would like to have big plots if possible.
Something like in “My Restaurant”: 🍋🥤 My Restaurant! - Roblox

yes big plots as well… so just like My resteraunt

Try storing the item names as aliases. For example, for “Furnace”, save it as “FN” or something short.

Or, you could store the information in a format like that

local serialized = {
  Furnace = {
    {...}; -- the cframe components
    {...}; -- the cframe components
    {...}; -- the cframe components
  },
  Wall = {
    {...}; -- the cframe components
    {...}; -- the cframe components
    {...}; -- the cframe components
  }
}

This way, you will not need to repeat the item names again

So the best idea is to have a dedicated DataStore to store a dictionnary with all the placed items, something like this:

shorterName = {"Furnace" = "FN"}

local placedItems = {}
for i, item in pairs(plot:GetChildren()) do
   local info = {
      name = shorterNames[item.Name], -- So with a shorter Name like this
      x = item.Position.X,
      y = item.Position.Y,
      z = item.Position.Z,
      r = item.Rotation.Y -- I think it is the Y axe
   }

that's it?

I would recommend saving all values in a table. For something like this, I would strongly recommend DataStore2

1 Like

How can i get back the name of each objets to place them back?

Just do an array.

local ToSave = {
Data = {
Cash = 0;
etc..
}
Objects = {
Wall = {CFrame = Wall.CFrame:components(),Size = Wall.Size}
}
}

Is: “CFrame:components()” a real command wich returns an array with x, y, z pos?
But okay I understand, but I think i’ll split the save in two datastores, one for global things and the other one for Sand Box

CFrame:components returns all the “values” in the CFrame, X,Y,Z,Right vector,upvector,lookvector

Ok i did not know, thank you.
So i’ll try to mess with this using DSS2!

Thank you for all your help!

1 Like