How to use UserOwnsGamePassAsync()

There is not info in the docs so i want to understand how to use it

1 Like
local MarketplaceService = game:GetService("MarketplaceService")

local gamePassId = --ID of your gamepass, you can get it from a website url
local player -- i hope you do know how to get a player instance

if MarketplaceService:UserOwnsGamePassAsync(Player.UserId, gamePassId) then
    -- if player owns gamepass, the code in this block will be executed
end

Also MarketplaceService:UserOwnsGamePassAsync yields, if you’ll use it in listener of an event than can run multiple times (like .Touched) - don’t forget about debounce.

5 Likes

UserOwnsGamepassAsync() takes 2 parameters: userId and and gamepassId, userId is the player’s UserID, and gamepassId is the gamepass ID. It returns a bool value (true or false). If the player owns the gamepass, then it returns true, otherwise it returns false.

1 Like