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

Saving & loading tables using DataStore?

Asked by 9 years ago

Not that good at using DataStores, but tried this

local table1 ={} -- This is the table we will be saving.


ds = game:GetService("DataStoreService"):GetDataStore("A1") -- allows us to use datastore specific methods. you can add a scope if you want.


function Update()
local DataStore = game:GetService("DataStoreService"):GetOrderedDataStore("A1")

table1 = nil
print(DataStore)

for i,v in pairs(DataStore) do
table.insert(table1, i, v)
end
for index,value in pairs (table) do
ds:UpdateAsync(index, function() return value end) -- index will be our
end
end

script.Value.Changed:connect(function(property)
table.insert(table1, #table1, script.Value.Value)
Update()

end)

Answer this question