How i can Datastore a table

There is no difference between a table and a dictionary. A dictionary is a table, that’s it.

As long as you stop, as far as my knowledge goes.

I am wrong.

1 Like


its array :skull_and_crossbones: iits not a table

No, you can just save a table normally, below is an example:

-- Getting the data
local Data = DataStore:GetAsync(Player.UserId)

if Data then
   Gems.Value = Data.Gems
end
-- Example saving the data using SetAync
DataStore:SetAsync(Player.UserId, {Gems = Player.Gems.Value})

-- Example saving the data using UpdateAsync
DataStore:UpdateAsync(Player.UserId, function()
return {
Gems = Player.Gems.Value
}
end)

Looks like the error is coming from loading the data, and trying to set the value of a value to nil.

This could be due to a missing value in the PlayerData table.

An array is a table, a dictionary is a table. The difference is that an array exclusively has numerical indices (and no gaps) and a dictionary exclusively has non-numerical indices.

Edit: also tables store in datastores just fine, they’re internally encoded into json before saving, though keep in mind there are certain limitations like there cannot be mixed tables (tables with both numerical and non-numerical indices, in other words tables that are both a dictionary and an array).

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.