Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I keep a DevProduct from giving out benefits after used?

Asked by
Spooce 78
9 years ago

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
0
Simply use game passes? RM0d 305 — 9y
0
Oh sorry , I misread the thing. RM0d 305 — 9y

1 answer

Log in to vote
1
Answered by
DataStore 530 Moderation Voter
9 years ago

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.

Ad

Answer this question