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

Need help with saving values to a table, then saving the table?

Asked by
sad_eyez 162
6 years ago

This is not a request, just putting that out there, I know how to script a datastore, but I am curious, when you save values through a table in datastore, do you just put where the values are located in the table, and save the table the same way you would usually save a value?

I have never saved a values with a table before, I usually save the value itself.

1 answer

Log in to vote
1
Answered by 6 years ago

Here is how you would save a table to the DataStoreService:

local DS = game:GetService("DataStoreService"):GetDataStore("TableDS");

DS:SetAsync("Table", {"Apples", "Oranges", "Pineapples", "Grapes"});

You can get it like this:

local DS = game:GetService("DataStoreService"):GetDataStore("TableDS");

pcall(function()
    local test = DS:GetAsync("Table");
    print(test[1]);
end)
Ad

Answer this question