I have stored all the leaderstats in a dictionary
Example:
{
Wins = 0;
Points = 0;
KOs = 0
}
end
Error Gotten:
[Players:GetNameFromUserId() failed because HTTP 404 (NotFound)]
the problem is in ordereddatastores, I have two leaderboards one for kills and wins. The wins one works but the kills one doesn’t.
local DataStoreService = game:GetService("DataStoreService")
local KillStats = DataStoreService:GetOrderedDataStore(“KillStats_232432”)
local TimeUntilReset = 30
while true do
script.Parent.Parent.ResetTime.Text = "Resetting in " .. TimeUntilReset .. " seconds..."
for i, Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("IsDataLoaded") then
if Player.IsDataLoaded.Value == true then
KillStats:SetAsync(Player.UserId, Player.leaderstats.KOs.Value)
end
end
end
for i, LeaderboardRank in pairs(script.Parent:GetChildren()) do
if LeaderboardRank.ClassName == "Frame" then
LeaderboardRank:Destroy()
end
end
local success, errorMsg
local success, errorMsg = pcall(function()
local data = KillStats:GetSortedAsync(false, 50)
local KillStats = data:GetCurrentPage()
for RankInLeaderboard, DataStored in ipairs(KillStats) do
print(DataStored.value)
print(DataStored.key)
local UserName = game.Players:GetNameFromUserIdAsync(tonumber(DataStored.key))
local KOs = DataStored.value
local Template = script.Template:Clone()
Template.Name = UserName .. "Leaderboard"
Template.PlayerName.Text = UserName
Template.Rank.Text = "#" .. RankInLeaderboard
Template.Kills.Text = KOs
Template.Parent = script.Parent
end
end)
print(errorMsg)
wait(TimeUntilReset)
end