Advertisement
Dfgjfj

Untitled

Jan 11th, 2025
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. local DataStoreService = game:GetService("DataStoreService")
  2. local CoinsDataStore = DataStoreService:GetOrderedDataStore("CashLeaderBoardDataStore")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4.  
  5. local LeaderboardPart = script.Parent.Parent.Parent.Parent.LeaderboardPart
  6. local RefreshRate = 60
  7.  
  8. local function RefreshLeaderboard()
  9.  
  10. for i, Player in pairs(game.Players:GetPlayers()) do
  11.  
  12. CoinsDataStore:SetAsync(Player.UserId, Player.leaderstats.Cash.Value)
  13. end
  14.  
  15. local Success, Error = pcall(function()
  16.  
  17. local Data = CoinsDataStore:GetSortedAsync(false, 60)
  18. local RollsPage = Data:GetCurrentPage()
  19.  
  20. for Rank, SavedData in ipairs(RollsPage) do
  21.  
  22. local UserId = tonumber(SavedData.key)
  23. local Cash = SavedData.value
  24.  
  25. if Cash > 0 then
  26.  
  27. local Username = game.Players:GetNameFromUserIdAsync(UserId)
  28.  
  29. local NewSample = script:WaitForChild("Template"):Clone()
  30.  
  31. NewSample.Parent = LeaderboardPart.SurfaceGui.ScrollingFrame.Container
  32. NewSample.Name = Username
  33.  
  34. NewSample.RankLabel.Text = "#" .. Rank
  35. NewSample.NameLabel.Text = Username
  36. NewSample.NumberLabel.Text = Cash
  37.  
  38. if Rank == 1 then
  39.  
  40. NewSample.BackgroundColor3 = Color3.fromRGB(255, 213, 0)
  41.  
  42. elseif Rank == 2 then
  43.  
  44. NewSample.BackgroundColor3 = Color3.fromRGB(192, 192, 192)
  45.  
  46. elseif Rank == 3 then
  47.  
  48. NewSample.BackgroundColor3 = Color3.fromRGB(205, 127, 50)
  49.  
  50. else
  51.  
  52. NewSample.BackgroundColor3 = Color3.fromRGB(216, 216, 216)
  53. end
  54. end
  55. end
  56. end)
  57. end
  58.  
  59. while true do
  60.  
  61. for i, Frame in pairs(LeaderboardPart.SurfaceGui:WaitForChild("ScrollingFrame").Container:GetChildren()) do
  62.  
  63. if Frame.Name ~= "Template" and Frame:IsA("Frame") then
  64.  
  65. Frame:Destroy()
  66. end
  67. end
  68.  
  69. RefreshLeaderboard()
  70.  
  71. task.wait(RefreshRate)
  72. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement