Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local players = game:GetService("Players")
- local dataStoreService = game:GetService("DataStoreService")
- local globalDataStore = dataStoreService:GetOrderedDataStore("CoinsGloball")
- local board = game.Workspace.GlobalBoard
- local template = board.Main.SurfaceGui.Leaderboard.Template:Clone()
- board.Main.SurfaceGui.Leaderboard.Template:Destroy()
- local function update()
- for _,child in pairs(board.Main.SurfaceGui.Leaderboard:GetChildren()) do
- if child:IsA("Frame") then
- child:Destroy()
- end
- end
- local success,err = pcall (function()
- local data = globalDataStore:GetSortedAsync(false,20)
- local page = data:GetCurrentPage()
- for rank,plrData in ipairs(page) do
- local userid = plrData.key
- local coins = plrData.value
- if rank < 3 then
- local npc = workspace:FindFirstAncestor(rank)
- if npc then
- npc.UserId.Value = userid
- end
- end
- local new = template:Clone()
- new.PlrName.Text = players:GetNameFromUserIdAsync(userid)
- new.PlrAmount.Text = coins
- new.LayoutOrder = rank
- new.Parent = board.Main.SurfaceGui.Leaderboard
- end
- end)
- end
- while true do
- update()
- wait(math.random(2,5))
- spawn (function()
- for _,plr in pairs(game.Players:GetPlayers()) do
- globalDataStore:SetAsync(plr.UserId,plr.leaderstats.Coins.Value)
- wait()
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement