Guest User

Untitled

a guest
Apr 11th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1. -- Originally written by me, rewritten by @Feahren
  2. local MarketPlaceService = game:GetService("MarketplaceService")
  3. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  4. local ServerStorage = game:GetService("ServerStorage")
  5. local Players = game:GetService("Players")
  6.  
  7. local RobuxDonationData = game:GetService("DataStoreService"):GetOrderedDataStore("DonationData")
  8. local RobuxDonateEvent = ReplicatedStorage:WaitForChild("EventsFolder"):WaitForChild("RobuxDonateEvent")
  9.  
  10. local DataPageRequest = 15
  11.  
  12. local Leaderboard = workspace:WaitForChild("GlobalLeaderboard")
  13. local BoardGUI = Leaderboard:WaitForChild("lbGUI")
  14. local BoardSlots = BoardGUI:WaitForChild("Holder")
  15.  
  16. local function UpdateLeaderBoard()
  17.     print("Updating LeaderBoard...")
  18.         local Response = RobuxDonationData:GetSortedAsync(false, DataPageRequest)
  19.         local RobuxDataPage = Response:GetCurrentPage()
  20.         for _, RobuxData in ipairs(RobuxDataPage) do
  21.             local Username = Players:GetNameFromUserIdAsync(tonumber(RobuxData.key))
  22.             print(Username)
  23.             local TotalDonated = RobuxData.value
  24.             local IsOnLeaderboard = false
  25.             for _, Slot in pairs(BoardSlots:GetChildren()) do
  26.                 if (Slot.Player.Text == Username) then
  27.                     IsOnLeaderboard = true
  28.                     print("Player Is On LeaderBoard? "..IsOnLeaderboard.."!")
  29.                     break
  30.                 else
  31.                     print("Player Is On LeaderBoard? "..IsOnLeaderboard.."!")
  32.                 end
  33.             end
  34.             if (TotalDonated and not IsOnLeaderboard) then
  35.                 local Slot = ServerStorage:WaitForChild("lbFrame"):Clone()
  36.                 Slot.Player.Text = Username
  37.                 Slot.Amount.Text = tostring(TotalDonated)
  38.                 Slot.Position = UDim2.new(0, 0, (Slot.Position.Y.Scale + (0.08 * #BoardSlots:GetChildren())), 0)
  39.                 Slot.Parent = BoardSlots
  40.                 print("Slot Cloned")
  41.             end
  42.         end
  43. end
  44.  
  45. local function ProcessReceipt(ReceiptInfo)
  46.     local Completed = Enum.ProductPurchaseDecision.PurchaseGranted
  47.     local NotProcessed = Enum.ProductPurchaseDecision.NotProcessedYet
  48.     local Player = game:GetService("Players"):GetPlayerByUserId(ReceiptInfo.PlayerId)
  49.     if (Player) then
  50.         spawn(function()
  51.             repeat wait() until Completed
  52.             RobuxDonationData:IncrementAsync(ReceiptInfo.PlayerId, ReceiptInfo.CurrencySpent)
  53.             BoardSlots:ClearAllChildren()
  54.             UpdateLeaderBoard() -- Error Here
  55.         end)
  56.         return Completed
  57.     end
  58.     return NotProcessed
  59. end
  60.  
  61. MarketPlaceService.ProcessReceipt = ProcessReceipt
Advertisement
Add Comment
Please, Sign In to add comment