Datastore2 Table Saving

Hello, i have a question on the module Datastore2, How would I save tables, table values, etc,

Example:

local tab = {
newPlr = false
}

how would I save, update the table like a normal int value in datastore, I’m trying to save this for if statements etc, if anyone could help me it would help me a ton.
any examples would be helpfull.

1 Like

I believe you save tables the same way you would save any other form of data for DataStore2. Try looking at the github for documentation. Although I have never tried saving tables, I would assume that you just use the PlayerDataStore:Set() method to set the table to whatever you want:

local PlayerDataStore = DataStore2(player, "Key")

PlayerDataStore:Set(YourTable)

Sorry if this was vague, I can provide a more definitive example if needed.

Could you , if you can i would appreciate it

1 Like

Ok, I will try. The API will explain it better though.

It might be better if i just write some code:

local DataStore2 = require(PathToModule) --Wherever the module is located
local SwordStore = DataStore2("Swords", player) -- You have to have the specific player

local SwordStoreData = SwordStore:GetTable( --Set defualt values if player has no data
 Wooden = true,
 Silver = false,
 Gold = false
)

WeaponUnlocked.Event:Connect(function(player, NewWeaponTable) --Pretend bindable event
 SwordStore:Set(NewWeaponTable)
end)