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

My marketplace wont let purchases go through?

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. And yes, I do have the right code in the right type of scripts. Here is the script, and the other script that goes along with it inside of the button:

Script in GUI button (local script)

local ProductId = 45579253 
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function()
    Game:GetService("MarketplaceService"):PromptProductPurchase(player, ProductId)
end)

Script that handles purchases (normal script)

local MarketplaceService = game:GetService("MarketplaceService")
local LowID = 45579253
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
            end
        end 
    end
    PurchaseHistory:SetAsync(playerProductKey, true)    
    return Enum.ProductPurchaseDecision.PurchaseGranted     
end

Answer this question