Saving player builds

Hi. So I am making a building game but I ran into an issue. So every player has a “world” they can create and join and build in.

Currently the game saves it all to one datastore key, but when I checked out the size for a small cafe it’s approaching 210k (the limit is 260k) characters. Not good at all.

Does anyone have an idea (I don’t need code) how I can fix this? I need to split them up into different keys but I don’t know the best way to do so is.

I thought of maybe saving each block to it’s own key, but then how would I generate the key? Maybe based on the block position? How would I keep track of all the blocks and their keys, or are there better ways of doing it?

Here’s the gif of the building system as you can see players can customize a LOT of stuff https://gyazo.com/feadc68bea2e9e3a7c75b4b1657e8eeb

If anyone has an idea, I’d appreciate your help.

you could have a certain key for each different category of what they can place like
walls/roof, furniture, and decor

My bad. I forgot to include what I am saving. I updated the post with a gif.

you could try for every ? blocks create a new storage and save the storage number with its the amount of saves it has on another list

so something like this

  • savedList = {save1,savesfor1,save2,savesfor2}

  • then save using

for i,v in pairs(blocks:GetChildren())do
if i > ? and i < ?*2 then
add i to save1-1’s list
end
end
savesfor1 = math.ceil( #blocks:GetChildren()/?)

  • then get the saves using

for count = 1,#savesfor1 do
load peices in save1-1
end

`

1 Like

Actually, that sounds plausible. I’ll try it out and mark it as a solution for now!

im using datastore2 :flushed:
sorry if it makes an error, i dont use auto fill

local ds2 = require(path.to.datastore2)
ds2.Combine('stuff', 'build')

function SaveModel(player, model)
local stuff_data = {}
for index, object in next, model:GetChildren() do
stuff_data[#stuff_data+1] = {Pos = {X = object.Position.X, Y = object.Position.Y, Z = object.Position.Z}, Size = {X = object.Size.X, Y = object.Size.Y, Z = object.Size.Z}}
end
local Data = ds2('build', player)
Data:Set(stuff_data)
local s,m = pcall(function()
Data:Save()
end
if not s then
Data:SaveAsync()
end
end

Doesn’t that save to 1 key only? Sorry I’ve never used DS2 so I might be wrong

no

this is a text so devforum lets me say a single word