PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

PlayerHasPass

This function will not work with new game passes, use `MarketplaceService/UserOwnsGamePassAsync` instead.

This function returns true if the Player has the specified legacy game pass.

The result of this function may be cached, meaning it should not be relied on to give an up to date result.

For more information about game passes, please see [this article][1].

Legacy Game Passes

Historically, game passes on Roblox had an Asset ID associated with them. Although game passes created with an Asset ID still have an Asset ID, they now also have a Game Pass ID. All new game passes created today only have a Game Pass ID.

You can retrieve the Game Pass ID of any pass through its URL, for example the Game Pass ID of the below pass is 1:

https://www.roblox.com/game-pass/1/myGamePass

Whether you are using an Asset ID or a Game Pass ID determines which API members you can use.

Works with Asset ID (Legacy) Works with Game Pass ID (Current)
Verify Ownership GamePassService:
PlayerHasPass
MarketplaceService:
UserOwnsGamePassAsync
Prompt a purchase MarketplaceService:
PromptPurchase
MarketplaceService:
PromptGamePassPurchase
Prompted purchase finished MarketplaceService.
PromptPurchaseFinished
MarketplaceService.
PromptGamePassPurchaseFinished

API members that work with Asset IDs will not work with new game passes as they do not have them.

Parameters

Name Type Default Description

The Player for which to check ownership

The Asset ID of the game pass. This is not the Game Pass ID (see above)

Returns

Return Type Summary

Whether the Player owns the game pass


Code Samples


GamePassService:PlayerHasPass

The below example will print whether or not the recently joined player owns the ’ with the ID of 103728213.

local id = 103728213

game.Players.PlayerAdded:Connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        print(player.Name .. " has the game pass!")
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)