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

how to make a deaths leaderboarrd?

Asked by 5 years ago

make a leaderboard that shows rank,playername and number of deaths but i keep getting an errormsg : ServerScriptService.DeathsLeaderboardHandler:7: attempt to index nil with 'GetCurrentPage' cript:

01local DataStoreService = game:GetService("DataStoreService")
02local DeathsLeaderboard = DataStoreService:GetOrderedDataStore("DeathsLeaderboard")
03 
04local function updateLeaderboard()
05    local success, errorMessage = pcall(function()
06        local Data = DeathsLeaderboard:GetAsync(false, 5)
07        local DeathsPage = Data:GetCurrentPage()
08        for Rank, data in ipairs(DeathsPage) do
09            local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
10            local Name = userName
11            local Deaths = data.value
12            local isOnLeaderboard = false
13            for i, v in pairs(game.Workspace.Spawn.DeathsGlobalLeaderboard.SurfaceGui.Holder:GetChildren()) do
14                if v.Player.Text == Name then
15                    isOnLeaderboard = true
View all 50 lines...

i am getting the Updated Deaths Leaderboard msg though.

1 answer

Log in to vote
0
Answered by 5 years ago

guys i figured it out but the msg when i was about to delete this question told me other wise

i put GetSortedAsync rather than GetAsync

line 6

01local DataStoreService = game:GetService("DataStoreService")
02local DeathsLeaderboard = DataStoreService:GetOrderedDataStore("DeathsLeaderboard")
03 
04local function updateLeaderboard()
05    local success, errorMessage = pcall(function()
06        local Data = DeathsLeaderboard:GetSortedAsync(false, 5)
07        local DeathsPage = Data:GetCurrentPage()
08        for Rank, data in ipairs(DeathsPage) do
09            local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
10            local Name = userName
11            local Deaths = data.value
12            local isOnLeaderboard = false
13            for i, v in pairs(game.Workspace.Spawn.DeathsGlobalLeaderboard.SurfaceGui.Holder:GetChildren()) do
14                if v.Player.Text == Name then
15                    isOnLeaderboard = true
View all 50 lines...
Ad

Answer this question