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

Help with OrderedDataStores?

Asked by 8 years ago
local data = game:GetService("DataStoreService"):GetDataStore('Stats')
local ods = game:GetService('DataStoreService'):GetOrderedDataStore("Time")
local gsa = ods:GetSortedAsync(false, 100)
local values = {}

game.Players.PlayerRemoving:connect(function(p2)
    p2:WaitForDataReady()
    wait(5)
    local time2 = p2:FindFirstChild("leaderstats"):GetChildren()
    for i = 1, #time2 do
        data:SetAsync(time2[i].Name, time2[i].Value)
    end
end)

game.Players.PlayerAdded:connect(function(p)
    p:WaitForDataReady()
    wait(5)
    local time1 = p:FindFirstChild("leaderstats"):GetChildren()
    for i = 1, #time1 do
        time1[i].Value = data:GetAsync(time1[i].Name)
    end
end)

for _, v in ipairs(gsa:GetCurrentPage()) do
    values[#values + 1] = v  --  table.insert(values, v)
end 

for i = 1, #values do
    local x = Instance.new('IntValue', game.Workspace)
    x.Value = values[i]
end

for i, v in pairs(game.Workspace:GetChildren()) do
    if v:IsA'IntValue' then
        print(v.Value)
    end
end

Trying to receive all the values and make a IntValue for them.

0
Use NumberValue if you dont want people's stats to be limited at 2 billion. User#26354 0 — 5y

Answer this question