-
What do you want to achieve? Keep it simple and clear!
I want to find a way to fix the leaderboards to have them display all data. -
What is the issue? Include screenshots / videos if possible!
In the leaderstats, you can see that I have 19 kills and 5,700 highest time. If you look at the kills leaderboard, there’s nothing displayed even though you can see my kills. Previously when these were working, there were around 15 names listed on both leaderboards. Now, there are two names listed on the “Most Time” leaderboard and none on the most kills. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t tried much since I couldn’t find any similar issues to mine. There are 0 errors in the output relating to leaderboards.
Here are the scripts inside of the leaderboards, datastore script is somewhere else. If you need the DSS script please let me know.
Kills LB script:
local DataStore = game:GetService('DataStoreService')
local OrderedDataStore = DataStore:GetOrderedDataStore('KillsLB2')
local cache = require(game.ServerScriptService["Server/Data"].ProfileCacher)
local refreshTime = 2
local ResetTimer = script.Parent.Parent.ResetTimer
while true do
wait(1)
refreshTime -= 1
ResetTimer.Text = "Leaderboard refreshes in " .. refreshTime .. " seconds!"
if refreshTime == 0 then
refreshTime = 60
for index, plr in pairs(game.Players:GetChildren()) do
local profile = cache[plr]
if profile ~= nil then
OrderedDataStore:SetAsync(plr.UserId, profile.Data.Kills)
end
end
for index, list in pairs(script.Parent:GetChildren()) do
if list.ClassName == 'Frame' then
list:Destroy()
end
end
local success, errorMessage = pcall(function()
local data = OrderedDataStore:GetSortedAsync(false, 40)
local currentPage = data:GetCurrentPage()
for currentRank, storedData in ipairs(currentPage) do
local name = game.Players:GetNameFromUserIdAsync(tonumber(storedData.key))
local time = storedData.value
local cloneList = script.Template:Clone()
cloneList.Name = name .. " 's leaderboard rank"
cloneList.Username.Text = name
cloneList.Rank.Text = currentRank
cloneList.Amount.Text = time
cloneList.Parent = script.Parent
end
end)
end
end
Time LB script:
local DataStore = game:GetService'DataStoreService'
local OrderedDataStore = DataStore:GetOrderedDataStore('KillsLB1')
local cache = require(game.ServerScriptService["Server/Data"].ProfileCacher)
local refreshTime = 2
local ResetTimer = script.Parent.Parent.ResetTimer
while true do
wait(1)
refreshTime -= 1
ResetTimer.Text = "Leaderboard refreshes in " .. refreshTime .. " seconds!"
if refreshTime == 0 then
refreshTime = 60
for index, plr in pairs(game.Players:GetChildren()) do
local profile = cache[plr]
if profile ~= nil then
OrderedDataStore:SetAsync(plr.UserId, profile.Data.HighestTime)
end
end
for index, list in pairs(script.Parent:GetChildren()) do
if list.ClassName == 'Frame' then
list:Destroy()
end
end
local success, errorMessage = pcall(function()
local data = OrderedDataStore:GetSortedAsync(false, 100)
local currentPage = data:GetCurrentPage()
for currentRank, storedData in ipairs(currentPage) do
local name = game.Players:GetNameFromUserIdAsync(tonumber(storedData.key))
local time = storedData.value
local cloneList = script.Template:Clone()
cloneList.Name = name .. " 's leaderboard rank"
cloneList.Username.Text = name
cloneList.Rank.Text = currentRank
cloneList.Amount.Text = time
cloneList.Parent = script.Parent
end
end)
end
end
Thanks!