-
What do you want to achieve? i want to achieve leaderboard
-
What is the issue? Include screenshots / videos if possible!
i figured out its line 8 by removing pcall when adding back
here’s the code:
local DataStoreService = game:GetService('DataStoreService')
local WinsLeaderboard = DataStoreService:GetOrderedDataStore('WinsLeaderboard')
local function UpdatLeaderboard()
local success,errorMessage = pcall(function()
local Data = WinsLeaderboard:GetSortedAsync(false,5) -- error
for rank, data in pairs(Data:GetCurrentPage()) do
local UserName = game.Players:GetNameFromUserIdAsync(tonumber(data.Key))
local Name = UserName
local Wins = data.Value
local IsOnLeaderboard = false
for i, v in pairs(game.Workspace.leaderboard.SurfaceGui.ScrollingFrame:GetChildren()) do
if v:IsA('Frame') then
if v:FindFirstChild('Player').Text == Name then
IsOnLeaderboard = true
break
end
end
if Wins and IsOnLeaderboard == false then
local newLbFrame = game.ReplicatedStorage:WaitForChild('leaderboard_frame'):Clone()
newLbFrame.Name = tostring(rank)
newLbFrame.Parent = workspace.leaderboard.SurfaceGui.ScrollingFrame
newLbFrame.Player.Text = Name
newLbFrame.Rank.Text = '#'..rank
newLbFrame.Wins.Text = tostring(Wins)
end
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, Player in pairs(game.Players:GetPlayers()) do
WinsLeaderboard:SetAsync(Player.UserId,Player.leaderstats.Wins.Value)
end
for _, frame in pairs(game.Workspace.leaderboard.SurfaceGui.ScrollingFrame:GetChildren()) do
if frame:IsA('Frame') then
frame:Destroy()
end
end
UpdatLeaderboard()
print('updated')
wait(10)
end
here is the screenshot of output error
pre last line of output is the error
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
i tried browsing for the people same as i, but eventually i didnt find anything.
also changing Data:GetCurrentPage()
to variable and back
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
can you please write where is my mistake and how to fix it?