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

Gamepass ID not found? Wrong ID?

I have a game that gives a tool only if a game pass is bought. By clicking this part, it detects the purchase and either rewards it or prompts the pass. The problem is, when I input the id into the script the marketplace believes it is another item off-sale from another creator! As a matter of fact, the popup is an image of a t-shirt graphic that has not been accepted by moderators. I have searched for the game pass id in the URL but it is all the same. What am I missing? Is this the wrong id? The game pass id I find from the URL is 5433658 but it will not accept it. Game pass: https://www.roblox.com/game-pass/5433658/M60 Some of my code:

local id = 5433658
local marketplaceService = game:GetService("MarketplaceService") 

Then, to identify the pass I use:

function isAuthenticated(player)
return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, id) 

end

Prompt the pass:

game:GetService("MarketplaceService"):PromptPurchase(player,id)

m60:Destroy()

Can somebody give me some tips or identify an error? Perhaps send a link on the wiki to find the actual ID? Thank you.

1 answer

✓ Accepted answer

Issues

The reason you are getting another person's shirt asset is that you can no longer use :PlayerOwnsAsset to retrieve Gamepasses.

Instead, you have to use :UserOwnsGamePassAsync which has parameters pertaining to the player's UserId and the id of the gamepass

Revised Server Script Code

function isAuthenticated(player)
    return game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, id)
end

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