Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

this is how you make a game pass?

Asked by 10 years ago

this is what you do to make a game pass HERE!

local passId = 0000000 -- change this to your game pass ID.

function isAuthenticated(player) -- checks to see if the player owns your pass
    return game:GetService("GamePassService"):PlayerHasPass(player, passId)
end

game.Players.PlayerAdded:connect(function(plr)
    if isAuthenticated(plr) then
        print(plr.Name .. " has bought the game pass with id " .. passId)
    end
end)

Example:

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)

Alternatively, you could use ternary operators to make the above code shorter.

local id = 103728213

game.Players.PlayerAdded:connect(function(player)
    local HasPass = Game:GetService("GamePassService"):PlayerHasPass(player, id)
    print(player.Name .. (HasPass and " has" or " doesn't have").. " the game pass!")
end)

Thank you for reading.

Answer this question