How to hide a UI to people who don't have a certain gamepass?

What do you want to achieve?
I want to hide a UI to people who don’t have a certain gamepass.

What is the issue?
I don’t know how to do.

What solutions have you tried so far?
I searched on the internet and in Roblox Documentation.

Thanks if you help me, have a good day!

I believe that MarketplaceService is what you are looking for.

Specifically, MarketplaceService:UserOwnsGamePassAsync()
It takes 2 parameters, the Player’s UserId, and the GamepassId

It returns true or false depending on if the user owns a gamepass.

To apply it to your situation, I would do this: (Server Script)

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local GamePassID = 999999 -- Add the gamepass ID here

local function PlayerAdded(Player)
    local UserID = Player.UserId
    local UserOwnsGamepass = MarketplaceService:UserOwnsGamePassAsync(UserID, GamePassID)
    if UserOwnsGamepass then
        -- Now the script knows that the player has the gamepass!
    end
end

Players.PlayerAdded:Connect(PlayerAdded)

Hum ok :thinking:

I’ll try that. Thanks!