Advertisement
HowToRoblox

CoinsHandler

Sep 30th, 2020
6,265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local mps = game:GetService("MarketplaceService")
  2.  
  3.  
  4. local coinsProductIDs =
  5. {
  6.     [1096714714] = 100,
  7.     [1096715119] = 500,
  8.     [1096715447] = 1000,
  9.     [1096715703] = 5000,
  10. }
  11.  
  12.  
  13. game.Players.PlayerAdded:Connect(function(plr)
  14.        
  15.     local ls = Instance.new("Folder")
  16.     ls.Name = "leaderstats"
  17.     ls.Parent = plr
  18.    
  19.     local coins = Instance.new("IntValue")
  20.     coins.Name = "Coins"
  21.     coins.Parent = ls
  22. end)
  23.  
  24.  
  25.  
  26. mps.ProcessReceipt = function(purchaseInfo)
  27.    
  28.    
  29.     local plrPurchased = game.Players:GetPlayerByUserId(purchaseInfo.PlayerId)
  30.    
  31.     if not plrPurchased then
  32.        
  33.         return Enum.ProductPurchaseDecision.NotProcessedYet
  34.     end
  35.    
  36.    
  37.     for productID, coinsGiven in pairs(coinsProductIDs) do
  38.        
  39.         if purchaseInfo.ProductId == productID then
  40.            
  41.            
  42.             plrPurchased.leaderstats.Coins.Value = plrPurchased.leaderstats.Coins.Value + coinsGiven
  43.            
  44.             return Enum.ProductPurchaseDecision.PurchaseGranted
  45.         end
  46.     end
  47. end
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement