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

Why wont my market place work? Failed to purchase?

Asked by
soutpansa 120
7 years ago

I made a market place service script that works just fine during test mode. The script gives a Gachapon that when opened, will give a random item. It works perfectly on test mode, but when I open it in the normal game it says that the purchase has failed and something went wrong. Here is the script, and the other script that goes along with it inside of the button:

local productId = 45579253

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()

    Game:GetService("MarketplaceService"):PromptProductPurchase(player, productId)

end)

local MarketplaceService = game:GetService("MarketplaceService")

local LowID, MedID = 45579253, 20754348

local PurchaseHistory = game:GetService("DataStoreService"):GetDataStore("PurchaseHistory")

local boo = game.Players.LocalPlayer

MarketplaceService.ProcessReceipt = function(receiptInfo)

    local playerProductKey = receiptInfo.PlayerId .. ":" .. receiptInfo.PurchaseId

    if PurchaseHistory:GetAsync(playerProductKey) then

        return Enum.ProductPurchaseDecision.PurchaseGranted

    end
    for i, player in ipairs(game.Players:GetPlayers()) do

        if player.userId == receiptInfo.PlayerId then

            if receiptInfo.ProductId == LowID then

                local o =game.Lighting.Gachapons.ChristmasGachapon:Clone()

        o.Parent = boo.Backpack

            elseif receiptInfo.ProductId == MedID then

                player.leaderstats.Money.Value = player.leaderstats.Money.Value + 500000 -- I don't use the MedID, but I keep it there incase I will ever put another item in to buy

            end

        end

    end

    PurchaseHistory:SetAsync(playerProductKey, true)   

    return Enum.ProductPurchaseDecision.PurchaseGranted    

end
1
You can't use ProcessReceipt in a LocalScript. Might I suggest reviewing this previously answered question? https://scriptinghelpers.org/questions/27112/ M39a9am3R 3210 — 7y
0
did not use ProcessReceipt in a local script, starting at line 11, it is a normal script. Should of specified that, sorry soutpansa 120 — 7y

Answer this question