Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I properly identify a gamepass?

Hi guys, i've made a shop GUI for my game and I've put in one of the gamepasses available for purchase, however when the button is pressed it comes up with a random shirt not for sale anymore. My guess is that ROBLOX has changed the way that gamepasses are identified and that I am not aware of this change.

local player = game.Players.LocalPlayer

local marketplaceService = game:GetService("MarketplaceService")

  

script.Parent.MouseButton1Click:connect(function()

marketplaceService:PromptPurchase(player, 6034291)

-- 6034291 is the ID that appears in the gamepass URL.

end)

Any help is appreciated!

3 comments

0

hmmm, i dont think so, are you sure that your id is right?

0
0

ok, 1 question, is this the shirt? https://www.roblox.com/catalog/6034291/im-gonna-fall

1 answer

✓ Accepted answer

General Practice

Use Activated instead of MouseButton1Click since Activated works for all devices and not just computers

Use :GetService() to retrieve the Players Service

connect is deprecated, use Connect instead

Issues

So you are right, this was changed (although this was not a recent update), gamepasses are now separate from assets in the catalog. The proper way to prompt their purchase is with the PromptGamePassPurchase Event of the MarketPlaceService

Revised Local Script

local player = game.Players.LocalPlayer
local marketplaceService = game:GetService("MarketplaceService")

script.Parent.Activated:Connect(function()
    marketplaceService:PromptGamePassPurchase(player, 6034291)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.