Retrieving and saving "global" block data

I currently have the following code:

local newBlock = block:Clone()
newBlock.Parent = workspace.Blocks
newBlock.Position = position
newBlock.Color = color
	
local data = {
	["Color"] = tostring(color),
	["Placer"] = player.UserId,
	["TimeStamp"] = os.time()
}
	
local key = tostring(position)

-- encode just for now just does JSONEncode
local sdata, skey = encode(data, key)

How am I able to save data in a way where I can access every block in the datastore and load it in on a fresh server (essentially getting every block placed in a way where I can loop through them)?

A block’s only tie to the player is in the ["Placer"] component, but that’s it. I don’t want to just load only the player’s blocks that are within the server, but rather, load every block placed by anyone. There doesn’t seem to be a simple way using normal datastores, and I can’t think of a way to use ordered datastores with this form of data.

I’m not the best with datastores, so sorry if this is a silly question. Thanks!

1 Like

You could put all the block tables into a bigger table. Something like this:

local plot = {
   {
      ["Color"] = tostring(color),
      ["etc"] = _,
   },

   {
      ["Color"] = tostring(color),
      ["etc"] = _,
   },
}
1 Like

Ok, I’ll try this out. Keys can hold 4 million chars, right?

1 Like

I’m not sure about a size limit, but I use this method for my own game.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.