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

Why won't this give the player the item when they buy the gamepass?

Asked by
Avoxea 48
5 years ago
market = game:GetService("MarketplaceService")

local marketPlace = game:GetService("MarketplaceService")
marketPlace.ProcessReceipt = function(receipt)
    player = game.Players:GetPlayerByUserId(receipt.PlayerId)
    if receipt.CurrencySpent == 300 then
        --gravity
        if true then
            return Enum.ProductPurchaseDecision.PurchaseGranted
        end
        game.ServerStorage.GravityCoil:Clone().Parent = player:WaitForChild("Backpack")
    elseif receipt.CurrencySpent == 1 then
        if true then
            return Enum.ProductPurchaseDecision.PurchaseGranted
        end
        game.ServerStorage["Acceleration Coil"]:Clone().Parent = player:WaitForChild("Backpack")
        --speed
    end
end

2 answers

Log in to vote
1
Answered by
Arkrei 389 Moderation Voter
5 years ago

Process Receipt is for dev products gamepass's have different things i'd recomend you look through the marketplace api wiki but this is what you need PromptGamePassPurchaseFinished

Ad
Log in to vote
0
Answered by
Avoxea 48
5 years ago

Thanks!! This worked.

market = game:GetService("MarketplaceService")
market.PromptGamePassPurchaseFinished:Connect(function(player, gamepass, purchase)
    if purchase == true then
        --gravity
        if gamepass == 6632153 then
        game.ServerStorage.GravityCoil:Clone().Parent = player.Backpack
        elseif gamepass == 6632270 then
        game.ServerStorage["Acceleration Coil"]:Clone().Parent = player.Backpack
        --speed
        end
    end
end)

Answer this question