I'm making a game and wanting a GUI to appear when they buy a certain gamepass. I found that MarketplaceService.PromptGamePassPurchaseFinished is a thing, I believe I'm using this incorrectly, how do I properly use this?
local MarketplaceService = game:GetService("MarketplaceService")
local DataStore2 = require(script.Parent:WaitForChild("MainModule"))
local pid1 = 703927122
local pid2 = 703927252
local pid3 = 703927369
local pid4 = 703927502
local pid5 = 715997494
MarketplaceService.ProcessReceipt = function(receiptInfo)
local newTable = bigCopy(plr)
local MasterData = DataStore2(currentData, plr)
for i, player in ipairs(game.Players:GetChildren()) do
if player.UserId == receiptInfo.PlayerId then
if receiptInfo.ProductId == pid1 then
wait(2)
newTable.Coins = newTable.Coins + 1000
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = true
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = "+1,000"
wait(1)
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = false
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = ""
elseif receiptInfo.ProductId == pid2 then
wait(2)
newTable.Coins = newTable.Coins + 3000
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = true
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = "+3,000"
wait(1)
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = false
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = ""
elseif receiptInfo.ProductId == pid3 then
wait(2)
newTable.Coins = newTable.Coins + 7750
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = true
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = "+7,750"
wait(1)
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = false
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = ""
elseif receiptInfo.ProductId == pid4 then
wait(2)
newTable.Coins = newTable.Coins + 13500
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = true
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = "+13,500"
wait(1)
player.PlayerGui.Main.Coins.Coin.AddedAmount.Visible = false
player.PlayerGui.Main.Coins.Coin.AddedAmount.Text = ""
elseif receiptInfo.ProductId == pid5 then
wait(2)
purchaseItem:FireClient(player, "CrateGui")
elseif MarketplaceService.PromptGamePassPurchaseFinished(7227010) then
wait(1)
vip:FireClient(player, "VIPSuccess")
end
end
MasterData:Set(newTable)
return Enum.ProductPurchaseDecision.PurchaseGranted
end
end
end)

5 comments
Yeah but I'm wanting to add the benefits VIP members get instantly.
You could always reset the player....xD
sorry sorry, re editing
I am hoping to do this with multiple multiple gamepasses and would I put the gamepass idea inside of the :Connect(function()?
Yep, you got it.