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
01market = game:GetService("MarketplaceService")
02 
03local marketPlace = game:GetService("MarketplaceService")
04marketPlace.ProcessReceipt = function(receipt)
05    player = game.Players:GetPlayerByUserId(receipt.PlayerId)
06    if receipt.CurrencySpent == 300 then
07        --gravity
08        if true then
09            return Enum.ProductPurchaseDecision.PurchaseGranted
10        end
11        game.ServerStorage.GravityCoil:Clone().Parent = player:WaitForChild("Backpack")
12    elseif receipt.CurrencySpent == 1 then
13        if true then
14            return Enum.ProductPurchaseDecision.PurchaseGranted
15        end
16        game.ServerStorage["Acceleration Coil"]:Clone().Parent = player:WaitForChild("Backpack")
17        --speed
18    end
19end

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.

01market = game:GetService("MarketplaceService")
02market.PromptGamePassPurchaseFinished:Connect(function(player, gamepass, purchase)
03    if purchase == true then
04        --gravity
05        if gamepass == 6632153 then
06        game.ServerStorage.GravityCoil:Clone().Parent = player.Backpack
07        elseif gamepass == 6632270 then
08        game.ServerStorage["Acceleration Coil"]:Clone().Parent = player.Backpack
09        --speed
10        end
11    end
12end)

Answer this question