I am having trouble creating a script that reward points after buying the developer product. The points are for a system I am using in-game that involves getting points via leaderstats. Whenever I try to add more than one ProccessReceipt, only the last one I added works.
Heres the code I am trying:
local MarketplaceService = game:GetService("MarketplaceService") local DataStoreService = game:GetService("DataStoreService") local currencyName = "A.P" local PreviousPurchases = DataStoreService:GetDataStore("PreviousPurchases") local bit_ap = 443047981 local some_ap = 443047297 local pocket_ap = 443047667 local hand_ap = 443046726 local lot_ap = 443048522 local heart_ap = 443049632 local insane_ap = 443051526 MarketplaceService.ProcessReceipt = function(receipt) --150 Ap -- Receipt has PurchaseID, PlayerID, ProdutID, CurrecnySpentValue, CurrencyType, PlaceIdWherePurchased local ID = receipt.PlayerId.."-"..receipt.PurchaseId local success = nil pcall(function() success = PreviousPurchases:GetAsync(ID) end) if PreviousPurchases:GetAsync(ID) then -- Has it been bought? -- Purchase has been done return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receipt.PlayerId) if not player then -- Left, disconnected return Enum.ProductPurchaseDecision.NotProcessedYet -- Give rewards on next join else if receipt.ProductId == bit_ap then -- They bought 125 ap player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 150 end pcall(function() PreviousPurchases:SetAsync(ID,true) end) return Enum.ProductPurchaseDecision.PurchaseGranted end end MarketplaceService.ProcessReceipt = function(receipt) --500 Ap -- Receipt has PurchaseID, PlayerID, ProdutID, CurrecnySpentValue, CurrencyType, PlaceIdWherePurchased local ID = receipt.PlayerId.."-"..receipt.PurchaseId local success = nil pcall(function() success = PreviousPurchases:GetAsync(ID) end) if PreviousPurchases:GetAsync(ID) then -- Has it been bought? -- Purchase has been done return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receipt.PlayerId) if not player then -- Left, disconnected return Enum.ProductPurchaseDecision.NotProcessedYet -- Give rewards on next join else if receipt.ProductId == some_ap then -- They bought 125 ap player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 500 end pcall(function() PreviousPurchases:SetAsync(ID,true) end) return Enum.ProductPurchaseDecision.PurchaseGranted end end MarketplaceService.ProcessReceipt = function(receipt) --750 Ap -- Receipt has PurchaseID, PlayerID, ProdutID, CurrecnySpentValue, CurrencyType, PlaceIdWherePurchased local ID = receipt.PlayerId.."-"..receipt.PurchaseId local success = nil pcall(function() success = PreviousPurchases:GetAsync(ID) end) if PreviousPurchases:GetAsync(ID) then -- Has it been bought? -- Purchase has been done return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receipt.PlayerId) if not player then -- Left, disconnected return Enum.ProductPurchaseDecision.NotProcessedYet -- Give rewards on next join else if receipt.ProductId == pocket_ap then -- They bought 125 ap player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 750 end pcall(function() PreviousPurchases:SetAsync(ID,true) end) return Enum.ProductPurchaseDecision.PurchaseGranted end end MarketplaceService.ProcessReceipt = function(receipt) --1000 Ap -- Receipt has PurchaseID, PlayerID, ProdutID, CurrecnySpentValue, CurrencyType, PlaceIdWherePurchased local ID = receipt.PlayerId.."-"..receipt.PurchaseId local success = nil pcall(function() success = PreviousPurchases:GetAsync(ID) end) if PreviousPurchases:GetAsync(ID) then -- Has it been bought? -- Purchase has been done return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receipt.PlayerId) if not player then -- Left, disconnected return Enum.ProductPurchaseDecision.NotProcessedYet -- Give rewards on next join else if receipt.ProductId == hand_ap then -- They bought 125 ap player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 1000 end pcall(function() PreviousPurchases:SetAsync(ID,true) end) return Enum.ProductPurchaseDecision.PurchaseGranted end end MarketplaceService.ProcessReceipt = function(receipt) --2000 Ap -- Receipt has PurchaseID, PlayerID, ProdutID, CurrecnySpentValue, CurrencyType, PlaceIdWherePurchased local ID = receipt.PlayerId.."-"..receipt.PurchaseId local success = nil pcall(function() success = PreviousPurchases:GetAsync(ID) end) if PreviousPurchases:GetAsync(ID) then -- Has it been bought? -- Purchase has been done return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receipt.PlayerId) if not player then -- Left, disconnected return Enum.ProductPurchaseDecision.NotProcessedYet -- Give rewards on next join else if receipt.ProductId == lot_ap then -- They bought 125 ap player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 2000 end pcall(function() PreviousPurchases:SetAsync(ID,true) end) return Enum.ProductPurchaseDecision.PurchaseGranted end end MarketplaceService.ProcessReceipt = function(receipt) --7500 Ap -- Receipt has PurchaseID, PlayerID, ProdutID, CurrecnySpentValue, CurrencyType, PlaceIdWherePurchased local ID = receipt.PlayerId.."-"..receipt.PurchaseId local success = nil pcall(function() success = PreviousPurchases:GetAsync(ID) end) if PreviousPurchases:GetAsync(ID) then -- Has it been bought? -- Purchase has been done return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receipt.PlayerId) if not player then -- Left, disconnected return Enum.ProductPurchaseDecision.NotProcessedYet -- Give rewards on next join else if receipt.ProductId == heart_ap then -- They bought 125 ap player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 7500 end pcall(function() PreviousPurchases:SetAsync(ID,true) end) return Enum.ProductPurchaseDecision.PurchaseGranted end end MarketplaceService.ProcessReceipt = function(receipt) --10000 Ap -- Receipt has PurchaseID, PlayerID, ProdutID, CurrecnySpentValue, CurrencyType, PlaceIdWherePurchased local ID = receipt.PlayerId.."-"..receipt.PurchaseId local success = nil pcall(function() success = PreviousPurchases:GetAsync(ID) end) if PreviousPurchases:GetAsync(ID) then -- Has it been bought? -- Purchase has been done return Enum.ProductPurchaseDecision.PurchaseGranted end local player = game.Players:GetPlayerByUserId(receipt.PlayerId) if not player then -- Left, disconnected return Enum.ProductPurchaseDecision.NotProcessedYet -- Give rewards on next join else if receipt.ProductId == insane_ap then -- They bought 125 ap player.leaderstats[currencyName].Value = player.leaderstats[currencyName].Value + 10000 end pcall(function() PreviousPurchases:SetAsync(ID,true) end) return Enum.ProductPurchaseDecision.PurchaseGranted end end
And I know its not the gui's either. Please help, thanks!