Say I have a product that gives you 500 cash. I use to cash to purchase an in-game item. But when you come back on, you have 500 cash again.
local MarketPlace = game:GetService("MarketplaceService") local DataStore = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory") local ProductID = 22492584 MarketPlace.ProcessReceipt = function(ReceiptInfo) for i, player in ipairs(game.Players:GetChildren()) do if player.userId == ReceiptInfo.PlayerId then if ReceiptInfo.ProductId == ProductID then player.Cash.Value = player.Cash.Value + 500 end end end local playerProductKey = "player_" .. ReceiptInfo.PlayerId .. "_purchase_" .. ReceiptInfo.PurchaseId DataStore:IncrementAsync(playerProductKey, 1) return Enum.ProductPurchaseDecision.PurchaseGrant end
You're returning PurchaseGrant, not PurchaseGranted.
**Edit: ** Though to answer the main question here (despite it being somewhat unneeded) -
If you wanted to make sure that you weren't awarding something twice you could add the receipt's PurchaseId to a 'DataStore' after the player is given what they've purchased.
PurchaseId is a unique identifier for a purchase, meaning that you would add an if statement to see whether that PurchaseId has already been used. If it had, simply return PurchaseGranted. If it hadn't continue on with awarding the item.