I am trying to make a global leaderboard and when I play nothing comes up on the board. Can someone see if I did something wrong.
local ds = game:GetService("DataStoreService")
local TopRaisedODS = ds:GetOrderedDataStore("TopRaisedStats")
local timeUntilReset = 2
local nosaveplayer = {""}
while wait(1) do
timeUntilReset = timeUntilReset - 1
if timeUntilReset == 0 then
timeUntilReset = 10
for i, plr in pairs(game.Players:GetPlayers()) do
if table.find(nosaveplayer,plr.Name) then
else
TopRaisedODS:SetAsync(plr.UserId, plr.leaderstats:WaitForChild("Raised", 10).Value)
end
end
for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local data = TopRaisedODS:GetSortedAsync(false, 50)
local TopRaisedPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(TopRaisedPage) do
local name
local userid
local success, errormsg = pcall(function()
name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
userid = dataStored.key
end)
if not success then
name = "Terminated User!"
userid = 50
end
local RobuxRaised = dataStored.value
local template = script.Template:Clone()
--template.Name = name .. "Leaderboard"
template.Info.Username.Text = "@" .. name
template.Info.Avatar.Image = "rbxthumb://type=AvatarHeadShot&id="..userid.."&w=150&h=150"
template.Info.Rank.Text = rankInLB
template.Stats.Raised.Text = require(game.ReplicatedStorage.CommaCreator).en(RobuxRaised)
template.Parent = script.Parent
if rankInLB == 100 then
local NPC = workspace:WaitForChild("NPC").RaisedNPC
local success, errormsg = pcall(function()
local HC = game.Players:GetHumanoidDescriptionFromUserId(userid)
NPC.MythzRB.Humanoid:RemoveAccessories()
NPC.MythzRB.Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(1))
wait(0.1)
NPC.MythzRB.Humanoid:ApplyDescription(HC)
end)
if not success then
warn(errormsg)
NPC.MythzRB.Humanoid:ApplyDescription(game.Players:GetHumanoidDescriptionFromUserId(1))
end
end
end
end)
end
end
Location of script
If needed here is the model