I would like to know how to make a script check if a player has a gamepass

How do I make a script check if a player has a gamepass

The UserOwnsGamePassAsync method of the MarketplaceService can be utilized to check if a player that’s in the game owns a gamepass.

Example:

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

local button = script.Parent

local GamepassId = -- Insert Id of the Gamepass here (number in web address bar when on the page of the Gamepass)

button.Activated:Connect(function() -- Whenever the LocalPlayer clicks on the button, this function will be activated
    local GamepassCheck = MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassId)

    if GamepassCheck then -- Utilizing the variable above, this will check if the LocalPlayer owns the Gamepass with the given Id
        print(player.Name.." owns the gamepass with the Id of "..GamepassId)
    end
end)
1 Like

where should this go? :thinking: :thinking:

The example is for a LocalScript that would be inside of a GuiButton, as denoted by the usage of LocalPlayer & that button is defined as script.Parent.

wait nvm im stupid :neutral_face: :neutral_face: :expressionless: :grimacing: :roll_eyes:

1 Like

thx but ima just make it when a player touches a brick it works btw i no how to do that

1 Like