Check if Player has Gamepass

I’m using the wiki to figure out how to determine if a player has a game pass: https://developer.roblox.com/api-reference/function/GamePassService/PlayerHasPass

I’m trying to check to see if a player has a game pass, and this isn’t working.

I’ve also tried

local success, doesPlayerOwnAsset = pcall(PlayerOwnsAsset, MarketplaceService, player, 6508305)
if doesPlayerOwnAsset then
    --idk something
end

which worked for doing badges, but I’m at a loss.

5 Likes

Right on the page: “This function will not work with new game passes, use MarketplaceService/UserOwnsGamePassAsync instead.”

6 Likes

UserOwnsGamePassAsync would work for this.

local MarketPlaceService = game:GetService"MarketPlaceService"
local function ownsgamepass(userid,gamepassid)
    local s,res = pcall(MarketPlaceService.UserOwnsGamePassAsync,MarketPlaceService,userid,gamepassid)
    if not s then
        res = false
    end
    return res
end
7 Likes

If you actually take a look at the PlayerHasPass Wiki page, it says that the function has been deprecated, meaning that it’s no longer suitable for current works. This function have the parameters userId and assetId. It still works for Game Passes that have been created in the past, but not now.

In the other, the replacement is to use the UserOwnsGamePassAsync function. When using this function, the parameters will be userId and gamePassId. The gamepassId you can still retrieve it through the URL.

3 Likes

Read the page? There’s a giant header right there making mention that you should use a different function.

Not what this category is for.

2 Likes

how would you get the return? like in order to read if it’s true or false

The link(s) above should have covered this for you but, UserOwnsGamePassAsync returns whether the player has bought a Game-pass or not

UserOwnsGamePassAsync returns true if the Player with the given UserId owns the game pass with the given game pass ID (not to be confused with asset ID).

Example:

local MarketPlaceService = game:GetService("MarketPlaceService ")

local PlayerBoughtThisGamePass =  MarketPlaceService.UserOwnsGamePassAsync(Userid, GamePassiD)

if PlayerBoughtThisGamePass then
  print("Player Has Bought This GamePass")
end

Just as recommendation in the future please refrain from bumping older topics( in some cases)!

Have a great day or night!

10 Likes