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)