Forja

Roblox game pass script

A pass players can buy for a perk: this one makes them faster. It checks who owns it when they join, gives the perk at each respawn, and has a button to buy it in your game.

Where it goes

  1. 1On the Creator Dashboard, open your game, go to Passes under Monetization, make a pass, set it for sale and copy its ID.
  2. 2Add the first script to ServerScriptService, and put your ID in PASS_ID.
  3. 3In StarterGui, add a ScreenGui with a TextButton in it. Add the second script as a LocalScript inside the button, with the same ID.
SpeedPass · a Script in ServerScriptService
-- From forja.us/tools/roblox-scripts/game-pass-- Gives the perk to players who own the pass.local MarketplaceService = game:GetService("MarketplaceService")local Players = game:GetService("Players")local PASS_ID = 0 -- your pass's idlocal PASS_SPEED = 28local owners = {}local function givePerk(character)	local humanoid = character:WaitForChild("Humanoid")	humanoid.WalkSpeed = PASS_SPEEDendlocal function onPlayerAdded(player)	player.CharacterAdded:Connect(function(character)		if owners[player] then			givePerk(character)		end	end)	local ok, owns = pcall(function()		return MarketplaceService:UserOwnsGamePassAsync(player.UserId, PASS_ID)	end)	if ok and owns then		owners[player] = true		if player.Character then			givePerk(player.Character)		end	endendPlayers.PlayerAdded:Connect(onPlayerAdded)Players.PlayerRemoving:Connect(function(player)	owners[player] = nilend)-- Bought while playing: the perk starts right away.MarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, passId, purchased)	if purchased and passId == PASS_ID then		owners[player] = true		if player.Character then			givePerk(player.Character)		end	endend)
BuyPassButton · a LocalScript in a TextButton in StarterGui
-- From forja.us/tools/roblox-scripts/game-pass-- Opens Roblox's window to buy the pass.local MarketplaceService = game:GetService("MarketplaceService")local Players = game:GetService("Players")local PASS_ID = 0 -- your pass's idscript.Parent.Activated:Connect(function()	MarketplaceService:PromptGamePassPurchase(Players.LocalPlayer, PASS_ID)end)

How it works

  • UserOwnsGamePassAsync asks Roblox if the player owns the pass. pcall keeps the script running if Roblox can't answer.
  • The perk is given on the server, at each respawn: a player's own device can't be trusted with it.
  • PromptGamePassPurchaseFinished gives it at once to someone who buys during play.

Make it yours

Another perk
Change what givePerk does, such as giving a tool from ServerStorage.
What to charge
You keep 70% of each sale: the tax calculator works out the price.
Want something more? The script generator can write it: “A game pass that doubles the coins a player gets, with a button to buy it”

Maps to try it on: simulator and tycoon maps

Start from a finished map, and your scripts have a game to run in.

More free Roblox scripts