Saving Tables to Datastores

Hello,
I am fairly new to saving tables to datastores. Could someone show me a full simple example of how to do that please?

I am currently trying to save this table :

[Player_UserId] = {
   PackedCards = {},
   NewCards = {},
   DuplicateCards = {},
}

You can use HttpService’s JSONEncode and JSONDecode functions to convert tables to strings (and strings back to tables). You can then save these strings as usual!

Relevant article: HttpService | Documentation - Roblox Creator Hub

1 Like

I’ve heard you don’t always need to do that since Datastores support tables.

As far as I know, DataStores do not save tables.

Did you try saving the table?

There’s a good chance you’re wrong but I am not sure lol.

They 100% do support tables

local DS = game:GetService("DataStoreService"):GetDataStore("TestDataStore")

DS:SetAsync("TestKey", {Adam = "Sandler"})
print(DS:GetAsync("TestKey").Adam) --Sandler
4 Likes

Hello,

Guess I was right.

I will try this out, thank you!

Thank you @Intended_Pun as well :smiley:

1 Like