I am making a leaderboard script. And i have some problems with saving the data. It says what the title says.
I have looked for other solutions on the devforum but none work
btw, i use ordered datastore
Here is the saving:
for _,Player in pairs(game.Players:GetPlayers()) do
local SaveData = {Player.leaderstats.Rounds.Value, Player.UserData.Time.Value, Player.UserId}
DS:SetAsync("user-"..Player.UserId, SaveData)
end
And here is the loading:
local Data = DS:GetSortedAsync(false, 52)
local CashPage = Data:GetCurrentPage()
local Rank = 0
for _, PlayerData in ipairs(CashPage) do
print(#PlayerData)
local Found, Name = pcall(function()
local NameP = game:GetService("Players"):GetNameFromUserIdAsync(PlayerData[1][3])
return NameP
end)
if Found then
if Name ~= "epicboyman3" and Name ~= "williampay" then
Rank = Rank+1
local Name = Name
local Cash = PlayerData[1][1]
local NewObj = game.ReplicatedStorage:WaitForChild("lbFrame"):Clone()
NewObj.Player.Text = Name
NewObj.Cash.Text = Cash
NewObj.Rank.Text = "#"..Rank
NewObj.Position = UDim2.new(0, 0, NewObj.Position.Y.Scale + (0.0125 * #game.Workspace.GlobalLeaderboard.lbGUI.Holder:GetChildren()), 0)
NewObj.Parent = game.Workspace.GlobalLeaderboard.lbGUI.Holder
end
else
print(tostring(Found).. " Data ".. PlayerData[1][3])
end
end