Being able to save VIP server maps

Hi guys, in my game players are able to build custom maps/builds in vip servers and I would like to add an admin command to be able to save their map using Datastore.

Using this thread for reference, I’m aware I can come up with a string table and store it in a key. However, I’m concerned about data limits.

So I came up with an idea: to somehow split the data that goes over the character limit and store them into multiple keys, as many as needed. Then I can store the key names in a set datastore.

This is what I came up with:

VIPMapDataStore = game:GetService('DataStoreService'):GetDataStore('VIPMaps'),
DataToStore = {'assume', 'this', 'is', 'a', 'really', 'long', 'table', 'that', 'exceeds', 'data/character', 'limit'}

FunctionThatFiguresOutHowToSplitTableIntoMultipleTablesThatRespectsDataLimits()
local Tables = {}
-- ??????
return Tables
end

local Tables = FunctionThatFiguresOutHowToSplitTableIntoMultipleTablesThatRespectsDataLimits()
local Keys = #Tables
for i = 1,#Tables do
	local String = 
	VIPMapDataStore:SetAsync(game.PrivateServerId..'Key'..i, Tables[i]) -- Should I be worried about data failing to save? Wrap it pcall?
end
VIPMapDataStore:SetAsync(game.PrivateServerId..'Keys', Keys)

Loading it from here is easy, I’m just worried about the saving.
Is this an efficient way to do this? If so, how would I split the table into multiple tables that respect the limits? What is the limit?

If there’s a better way to do this, I’m open to that too.
I’m not willing to pay a 3rd party to store this data.

2 Likes

You may shorten as much as possible to fasten it, this is relative to how much data you must store but can always come handy, also avoid saving useless values.

Before running the line of code saving the parts, you’d need to make sure the server is a private server. You can do this by running this line of code right before the saving.

if game.PrivateServerId ~= "" then

end

This doesn’t answer my question at all. I’m asking about “FunctionThatFiguresOutHowToSplitTableIntoMultipleTablesThatRespectsDataLimits()”, more specifically, what the data limits are and how I could split a single table into multiple tables (only if it exceeds the limit) that respect the data limits.

From there, I can save the tables and easily load them.

I know how to tell a VIP server from one that isn’t a VIP server.

So you are trying to split the “DataToStore” into multiple parts or tables?

Save parts and properties into a table → Calculate whether I need to split the table into multiple, depending on if it exceeds the data limits → Save the table(s) → Save the amount of tables

The part in bold is what I’m having difficulty with.

In order to load the map, I would just:
Get how many tables were saved → Load those keys → Create new parts with the properties from the table(s)