Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
3

Is it possible to save tables to the Data Store?

Asked by 10 years ago

If I wanted to save a table that listed all the items a player has in game to the data store, could I? Is it even possible?

3 answers

Log in to vote
4
Answered by
jobro13 980 Moderation Voter
10 years ago

Yep. Data Store is designed to handle:

  • numbers
  • strings
  • tables
  • booleans

You can just enter a table in there!

So, side note: Data Persistence allowed to save instances: Data Store cannot (directly) do this. Data Store can save tables: Data Persistence cannot directly do this.

0
Also saves Boolean. Side note: Tables must be under 64,000 bytes from what I hear. FromLegoUniverse 264 — 10y
0
True. The string though, not the table. You need to convert the table to JSON (a string) and then count it. I'm not sure if it's 64k or 2^16 though. jobro13 980 — 10y
0
So, how exactly would I save a players inventory into a tabke? AwsomeSpongebob 350 — 10y
0
Want me to make my tool saving script using DataStoreService public? It works perfectly. :P FromLegoUniverse 264 — 10y
View all comments (2 more)
0
DataPersistence is deprecated, isn't it? Zenith_Lord 93 — 5y
0
I'm pretty sure it is since DataCost is deprecated property of all things. NGC4637 602 — 2y
Ad
Log in to vote
0
Answered by 6 years ago

Yes you can the script may contain error

local table = {a = "0",b = "0"} -- The main table
local ds = game:GetService("DataStoreService") -- datastore service
local hs = game.HttpService -- the http service
local nds = ds:GetDataStore("test")
local value = hs:JSONDecode(nds)
if value == nil then -- if it the first time you start the game then you start with the main table
    value = table
else
    value.a = value.a + 1 --we want to add 1 to a every time
    value.b = value.b + 2 --we want to add 2 to b every time
end
local encode = hs:JSONEncode(value)
hs:SetAsync("test",encode) -- may be it (encode,"test")
Log in to vote
-3
Answered by 10 years ago

" Introduction

ROBLOX is introducing a new API for storing data called Data Stores which is more powerful and robust than the old Data Persistence system. With Data Stores you can store arbitrary data which persists even when games are not running and can be accessed by all instances of a place in your game universe. You probably have used Data persistence. If you haven't, it's strongly suggested to learn how to use the Data Stores instead of the old Data Persistence. Here's a small overview on advantages over Data Persistence. For the disadvantages, see the limitations section. Data Stores have virtually no data limit. Data Persistance has a limit of 45000 data units per player. Data Stores are accessible from any place at any time in the same universe. If a call from the Data Store API returns, the data is confirmed to be saved. So, not data loss when a server crashes. Saves arbitrary lua tables, besides strings, booleans and numbers. Instances cannot be saved direcly though. We can test data stores in a local test server. If you are going to intensively use Data Stores, make sure that you have read the the limitations section too, to prevent frustrations later on. "

This is directly from Roblox Wiki -> http://wiki.roblox.com/index.php?title=Data_store

Answer this question