I have created 3 items that can be purchased with a Game Pass. Purchasing the item is working just fine, I’ve tested it, but the issue is that the items never appear into my Backpack to use. The systems takes me through the prompts to buy the items and says it was successful, it just does not ever show in the backpack.
The 3 items are Sword, monkey and flyingRock as show in the ReplicatedStorage of my Explorer.
This is the code in my MainGui
…
local MarketplaceService = game:GetService(“MarketplaceService”)
local MainFrame = script.Parent.MainFrame
local petGamepass1 = MainFrame.PetGamePassFrame1.PetGamepass1
local petGamepass2 = MainFrame.PetGamePassFrame2.PetGamepass2
local swordGamepass = MainFrame.SwordGamePassFrame.SwordGamepass
local Shop = MainFrame.Parent.Shop
local player = game.Players.LocalPlayer
local petGamepass1ID = 14004733
local petGamepass2ID = 14004754
local swordGamepassID = 13940834
petGamepass1.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass1ID)
end)
if hasPass then
print("player already has the gamepass")
else
MarketplaceService:PromptGamePassPurchase(player, petGamepass1ID)
end
end)
petGamepass2.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass2ID)
end)
if hasPass then
print("player already has the gamepass")
else
MarketplaceService:PromptGamePassPurchase(player, petGamepass2ID)
end
end)
swordGamepass.MouseButton1Down:Connect(function()
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, swordGamepassID)
end)
if hasPass then
print("player already has the gamepass")
else
MarketplaceService:PromptGamePassPurchase(player, swordGamepassID)
end
end)
Shop.MouseButton1Down:Connect(function()
MainFrame.Visible = not MainFrame.Visible
end)
…
& this is the code in Server Storage
…
local MarketplaceService = game:GetService(“MarketplaceService”)
local Players = game:GetService(“Players”)
local petGamepass1ID = 14004733
local petGamepass2ID = 14004754
local swordGamepassID = 13940834
game.Players.PlayerAdded:Connect(function(player)
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass1ID)
end)
if hasPass then
print("player has the gamepass")
local flyingRock = game.ReplicatedStorage.flyingRock:Clone()
flyingRock.Parent = player.Backpack
end
end)
local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)
if purchaseSuccess == true and purchasedPassID == petGamepass1ID then
print(player.Name.."purchased the game pass!")
local flyingRock = game.ReplicatedStorage.flyingRock:Clone()
flyingRock.Parent = player.Backpack
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
game.Players.PlayerAdded:Connect(function(player)
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, petGamepass2ID)
end)
if hasPass then
print("player has the gamepass")
local monkey = game.ReplicatedStorage.monkey:Clone()
monkey.Parent = player.Backpack
end
end)
local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)
if purchaseSuccess == true and purchasedPassID == petGamepass2ID then
print(player.Name.."purchased the game pass!")
local monkey = game.ReplicatedStorage.monkey:Clone()
monkey.Parent = player.Backpack
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
game.Players.PlayerAdded:Connect(function(player)
local success, message = pcall(function()
hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, swordGamepassID)
end)
if hasPass then
print("player has the gamepass")
local Sword = game.ReplicatedStorage.Sword:Clone()
Sword.Parent = player.Backpack
end
end)
local function onPromptGamePassPurchaseFinished(player, purchasedPassID, purchaseSuccess)
if purchaseSuccess == true and purchasedPassID == swordGamepassID then
print(player.Name.."purchased the game pass!")
local Sword = game.ReplicatedStorage.Sword:Clone()
Sword.Parent = player.Backpack
end
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(onPromptGamePassPurchaseFinished)
…