Advertisement
4zx16

Donation Board

Aug 14th, 2022 (edited)
1,279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.80 KB | Source Code | 0 0
  1. --[[
  2.  || 📜 AUTHOR: @4zx16 || Donation Board
  3. ]]
  4. local Product_Info = {
  5.     ID = 493388249;
  6.     Price = 5;
  7.     Currency = "ROBUX";
  8.     Debounce = true
  9. }
  10. local Services = {
  11.     DataStore = game:GetService("DataStoreService"):GetDataStore("Places");
  12.     MarketPlaceService = game:GetService("MarketplaceService")
  13. }
  14. local Raised = Services.DataStore:GetAsync(Product_Info.Currency.."_Raised")
  15.  
  16. if not Services.DataStore:GetAsync(Product_Info.Currency.."_Raised") then
  17.     Services.DataStore:SetAsync(Product_Info.Currency.."_Raised", 0)
  18. end
  19. script.Parent.SurfaceGui.Raised.ROBUX.Text = Product_Info.Currency.." "..Services.DataStore:GetAsync(Product_Info.Currency.."_Raised")
  20.  
  21. local function PrintOut(Value)
  22.     print(Value)
  23. end
  24. script.Parent.CD.MouseClick:connect(function(Player)
  25.     if Product_Info.Debounce then
  26.         if Player.UserId > 0 then
  27.             print 'Player is not a Guest!'
  28.             Services.MarketPlaceService:PromptProductPurchase(Player, Product_Info.ID)
  29.         end
  30.     end
  31. end)
  32. Services.MarketPlaceService.PromptProductPurchaseFinished:connect(function(UserId, ProductId, IsPurchased)
  33.     if Product_Info.Debounce then
  34.         Product_Info.Debounce = false
  35.        
  36.         if IsPurchased then
  37.             Services.DataStore:IncrementAsync(Product_Info.Currency.."_Raised", Product_Info.Price)
  38.             Services.DataStore:OnUpdate(Product_Info.Currency.."_Raised", PrintOut)
  39.             script.Parent.SurfaceGui.Raised.ROBUX.Text = Product_Info.Currency.." "..Services.DataStore:GetAsync(Product_Info.Currency.."_Raised")     
  40.             wait(7)
  41.         end
  42.         Product_Info.Debounce = true
  43.     end
  44. end)
  45. coroutine.resume(coroutine.create(function()
  46.     while wait() do
  47.         local Raised = Services.DataStore:GetAsync(Product_Info.Currency.."_Raised")
  48.         script.Parent.SurfaceGui.Raised.ROBUX.Text = Product_Info.Currency.." "..Services.DataStore:GetAsync(Product_Info.Currency.."_Raised")
  49.     end
  50. end))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement