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

Ordered Data Stores: Can i save a table?

Asked by
luachef 61
6 years ago

I'm working on a game, and these ordered data stores are something new to me. I have all my data auto saving to the standart data store. But i want to create global leaderboards. The question is: can i save my data table to an ordered data store? Or do i have to save each value for global leaderboard to a new data store?

0
Ordered data stores can only store integers. What I'd do is create an ordered data store for each stat, so no to your first question, yes to the second. UgOsMiLy 1074 — 6y

1 answer

Log in to vote
1
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Hello, luachef!

No, you can't save tables on OrderedDataStores, but you can on normal datastores

Saving normal Values:

game:GetService("DataStoreService"):GetDataStore("DataName"):SetAsync("Stats", 255) --This will save 255

This will also work: (Table)

game:GetService("DataStoreService"):GetDataStore("DataName"):SetAsync("Stats", {7, "This", "Is", "A", "Table"}) -- This will save a table with 7, "This", "Is", "A", "Table"

And this will also work: (Dictionary)

local SaveMe = {
    ["Level"] = 5,
    ["Name"] = "Leamir",
    ["Position"] = Vector3.New(0,0,0),
    ["Table"] = {"This", "Is", "A", "Table", "On", "A", "Dictionary"}
}
game:GetService("DataStoreService"):GetDataStore("DataName"):SetAsync("Stats", SaveMe) -- This will save the Dictionary SaveMe

Saving tables or dictionarys change the way you do to get the data, you'll need to treat the data like a table/Dictionary

To make a global leaderstat, you should save the Local Leaderstats on a table and then you should test it for all servers, to se where it should be added on the leaderboard

Good Luck with your games

Ad

Answer this question