So when i go to the testing place of my game this leaderboard works totally fine. But once i publish it to the main game it just breaks and doesnt show anything at all
local dss = game:GetService("DataStoreService")
local MoneyLeaderboard = dss:GetOrderedDataStore("LeaderboardDataSave")
local function updateLeaderboard()
local success, err = pcall(function()
local data = MoneyLeaderboard:GetSortedAsync(false,6)
local LevelPage = data:GetCurrentPage()
for r,d in ipairs(LevelPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(d.key))
local Name = userName
local Level = d.value
local IsOnLeaderboard = false
for i,v in pairs(script.Parent.SurfaceGui.Leaderboard:GetChildren()) do
if v.Rank.Text == Name then
IsOnLeaderboard = true
break
end
end
if IsOnLeaderboard == false then
local newFrame = game.ServerStorage.UI.LeaderboardRank:Clone()
newFrame.Rank.Text = Name
newFrame.Rank.Money.Text = "$"..tostring(Level)
newFrame.Position = UDim2.new(0,0,newFrame.Position.Y.Scale + (.13 * #script.Parent.SurfaceGui.Leaderboard:GetChildren()))
newFrame.Parent = script.Parent.SurfaceGui.Leaderboard
end
end
end)
if not success then
end
end
updateLeaderboard()
while wait(25) do
for i,p in pairs(game.Players:GetPlayers()) do
MoneyLeaderboard:SetAsync(p.UserId, p.leaderstats.Money.Value)
end
for i, f in pairs(script.Parent.SurfaceGui.Leaderboard:GetChildren()) do
f:Destroy()
end
updateLeaderboard()
end