I have this global leaderboard script. Before it worked fine but now i keep getting this:
I don’t really know how to fix it since i’m kinda bad with datastores, help would be appreciated!
The script:
local dataStoreService = game:GetService("DataStoreService")
local players = game:GetService("Players")
local globalDataStore = dataStoreService:GetOrderedDataStore("TheLabStatsTesting")
local board = script.Parent
local template = board.SurfaceGui.Leaderboard.Template:Clone()
board.SurfaceGui.Leaderboard.Template:Destroy()
local function update()
for _,child in pairs(board.SurfaceGui.Leaderboard:GetChildren()) do
if child:IsA("Frame") then
child:Destroy()
end
end
local success, err = pcall(function()
local data = globalDataStore:GetSortedAsync(false,40)
local page = data:GetCurrentPage()
for rank,plrData in ipairs(page) do
local userid = plrData.key
local HardWins = plrData.value
local new = template:Clone()
new.PlrName.Text = players:GetNameFromUserIdAsync(userid)
new.PlrAmount.Text = HardWins
new.LayoutOrder = rank
new.Rank.Text = "#"..rank
new.PlayerProfile.Image = "rbxthumb://type=AvatarHeadShot&w=150&h=150&id="..userid
new.Parent = board.SurfaceGui.Leaderboard
end
end)
end
while true do
update()
wait(60)
spawn(function()
for _,plr in pairs(game.Players:GetPlayers()) do
globalDataStore:SetAsync(plr.UserId,plr.leaderstats.HardWins.Value)
wait()
end
end)
end