Skip to content

Roblox Gamepass Script

Copy a free gamepass example, learn where it goes, then describe your own version.

Updated Oct 2026BeginnerExample · not runtime verified

Example: “Check whether a player owns my gamepass”

ScriptServerScriptService
Luau syntax (not run)Placement rules (not run)Sandbox startup (not run)Roblox (not run)
Gamepass.server.lua
local Players = game:GetService("Players")local MarketplaceService = game:GetService("MarketplaceService")local PASS_ID = 0 -- Replace with your gamepass IDlocal function checkPass(player)    local ok, owns = pcall(function()        return MarketplaceService:UserOwnsGamePassAsync(player.UserId, PASS_ID)    end)    if ok and player.Parent then        player:SetAttribute("HasVIP", owns)    elseif not ok then        warn("Gamepass lookup failed; try again later")    endendPlayers.PlayerAdded:Connect(checkPass)for _, player in Players:GetPlayers() do task.spawn(checkPass, player) endMarketplaceService.PromptGamePassPurchaseFinished:Connect(function(player, id, purchased)    if id == PASS_ID and purchased then checkPass(player) endend)

Where to put it

  1. Open your own experience in Roblox Studio and show the Explorer and Output panels.
  2. Replace PASS_ID with a gamepass you own. Keep privilege checks on the server.
  3. Insert a Script at ServerScriptService.
  4. Paste the code, press Play and test the behavior. Read Output if anything fails.

Line by line

1. Looks up ownership on the server.

2. Sets a HasVIP attribute for your own systems to read.

3. Refreshes access after a successful purchase.

Common mistakes

!
Check the object names and script location.

Names are case sensitive. A LocalScript needs a client execution context, while server data and permissions belong in a Script. Test with multiple players before publishing.

Gamepass script FAQ

Does this work in any Roblox game?
Use it in an experience you own or have permission to edit in Roblox Studio. It is not an external script injector.
Has this example been verified in Roblox?
No. This preview includes source examples and placement guides. Generated customizations show their actual check results, but Roblox execution is not connected. Test your copy in Studio.
Can I customize the example?
Yes. Copy or download the code and adjust it in Studio. AI customization is available through the generator, with check results shown for each generated script.

More script types