Advertisement
Sungmingamerpro13

New CoinsProduct

Feb 23rd, 2025
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.16 KB | None | 0 0
  1. --Developer Product Gui Button simplified by TehRandoms--
  2.  
  3. local devProductId = script.ID.Value    --The Developer Product ID if your item, must be a Product of the game place it is in
  4. local player = script.Parent.Parent.Parent.Parent.Parent
  5.  
  6. --Well, as always, don't touch anything below if you have no idea what you are doing--
  7.  
  8. --Prompt Buy--
  9. script.Parent.MouseButton1Click:connect(function()
  10.     game:GetService("MarketplaceService"):PromptProductPurchase(player, devProductId)
  11. end)
  12.  
  13. --Transaction--
  14. local MarketplaceService = game:GetService("MarketplaceService")
  15. local ds = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")
  16. MarketplaceService.ProcessReceipt = function(receiptInfo)
  17.     for i, player in ipairs(game.Players:GetChildren()) do
  18.         if player.userId == receiptInfo.PlayerId then
  19.             if receiptInfo.ProductId == devProductId then       --you can put the event here, or whatever
  20.                 player.Coins.Value = player.Coins.Value + 10
  21.             end
  22.         end
  23.     end
  24.     local playerProductKey = "player_" .. receiptInfo.PlayerId .. "_purchase_" .. receiptInfo.ProductId
  25.     ds:IncrementAsync(playerProductKey, 1) 
  26.     return Enum.ProductPurchaseDecision.PurchaseGranted
  27.  
  28. end
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement