How would I save a table using SetAsync?
You can use the http service. The script may has some 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")
You would save it as you would another type of data, but do remember the 65536 character limitation and that it saves the table encoded in JSON, to get the length of the encoded table length, doprint(string.length(game:GetService('HttpService'):JSONEncode(table)))
Example:
game:GetService('DataStoreService'):GetDataStore('AName'):SetAsync('table',{'a','b','c'}) local t = game:GetService('DataStoreService'):GetDataStore('AName'):GetAsync('table')
http://www.roblox.com/Forum/ShowPost.aspx?PostID=128157478 < That should help you.