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

Orderded Data Store Problems?

Asked by 8 years ago
Stat = "Lvl" 
DS = game:GetService("DataStoreService"):GetOrderedDataStore(Stat)
while true do
    wait(0.5)
    for i,p in pairs(game.Players:GetPlayers()) do
        DS:UpdateAsync(p.Name, p.leaderstats.Lvl.Value) -- Unable to cast value to function (error)
    end
    wait(24.5) 
end

Ive been reserching alot on the wiki about ODS and ive come accross the problem above ^ thanks for the help :)

1 answer

Log in to vote
0
Answered by 8 years ago

This would normaly working, it saves you data each second, even when a shutdown. Your leaderstats saves if you put this in a script 1-60 leaderstats will save in your game.

game.Players.PlayerRemoving:connect(function(p)
if p:findFirstChild("leaderstats") then
p:SaveInstance("SavedStatPNum"..tostring(game.PlaceId),p.leaderstats)
end
end)
game.Players.PlayerAdded:connect(function(p)
for k = 1, 60, 0.03 do
wait()
if p:findFirstChild("leaderstats") and p.DataReady then break end
end
local Loaded = nil
if p:findFirstChild("leaderstats") and pcall(function() Loaded =  p:LoadInstance("SavedStatPNum"..tostring(game.PlaceId)) end) then
for j, v in pairs(Loaded:GetChildren()) do
pcall(function() p.leaderstats[v.Name].Value = v.Value end)
end
end
end)
0
sorry, can you reword what you said before the code, it was kinda hard to understand Bubbles5610 217 — 8y
0
and my leaderstats work fine Bubbles5610 217 — 8y
0
put this in your workspace and normale evertything will saves minetrackmania 186 — 8y
Ad

Answer this question