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

Error when Calling ProcessReceipt?

Asked by 9 years ago

Yes, I know that there is a similar question that is supposedly solved already, but the answer seems to have been deleted and doesn't help me at all. I edited the Wiki's example code for the Developer Product to fit my needs, but I keep seeing this error message in the output: "ProcessReceipt is a callback member of MarketplaceService; you can only set the callback value, get is not available" it says the problem is with the last line of my code, but I don't even see a "get" type of method anywhere in the code except for the DataStore call. Here is the full script for reference:

local MarketplaceService = game:GetService("MarketplaceService")
local Eboost, Sboost, Dboost = 21588285, 21588295, 21588302
local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

function takeReceiptInfo(receiptInfo) 
    local playerProductKey = receiptInfo.PlayerId.. ":" ..receiptInfo.PurchaseId

    if PurchaseHistory:GetAsync(playerProductKey) then
        return Enum.ProductPurchaseDecision.PurchaseGranted --We already granted it.
    end

    -- find the player based on the PlayerId in receiptInfo
    for i, player in ipairs(game.Players:GetPlayers()) do
        if player.userId == receiptInfo.PlayerId then
            -- check which product was purchased (required, otherwise you'll award the wrong items if you're using more than one developer product)
            if receiptInfo.ProductId == Eboost then
                player.Boost.Value = 1
            elseif receiptInfo.ProductId == Sboost then
                player.Boost.Value = 2
            elseif receiptInfo.ProductId == Dboost then
                player.Boost.Value = 3
            end
        end 
    end

    -- record the transaction in a Data Store
    PurchaseHistory:SetAsync(playerProductKey, true)

    -- tell ROBLOX that we have successfully handled the transaction (required)
    return Enum.ProductPurchaseDecision.PurchaseGranted 
end

-- It SAYS this line is the problem:
MarketplaceService.ProcessReceipt:connect(takeReceiptInfo)

Answer this question