Skip to main content

GamePass

Game pass library that caches game pass ownership results and watches for pass purchases.

This module fixes the caching issue with UserOwnsGamePassAsync by saving purchases made in the server. This allows the user to continue playing without having to re-join.

local hasPass = GamePass.has(player.UserId, 123456)

Install with wally by adding the following to your wally.toml:

GamePass = "dig1t/gamepass@1.0.9"

Functions

has

GamePass.has(
playerPlayer,--

The Player to check.

gamePassIdnumber--

The game pass id to check.

) → boolean

Checks if a player has a game pass.

local hasPass = GamePass.has(player.UserId, 123456)

prompt

GamePass.prompt(
playerPlayer,--

The player to prompt.

gamePassIdnumber--

The game pass id.

) → ()

Prompts the player to purchase a game pass.

GamePass.prompt(player, 123456)

watch

GamePass.watch() → ()

Watches for game pass purchases. This allows the player to continue playing without having to re-join.

This is automatically called when using GamePass.onPurchase.

onPurchase

GamePass.onPurchase(
callbackCallback--

The callback to trigger.

) → ()

Types

type Callback = (
playerPlayer,
gamePassIdnumber
) → ()

Triggers a callback when a player purchases a game pass.

This calls GamePass.watch to start watching for game pass purchases.

To stop watching for game pass purchases, use GamePass.unwatch.

GamePass.onPurchase(function(player: Player, gamePassId: number)
	print(player.Name .. " purchased game pass " .. gamePassId)
end)

unwatch

GamePass.unwatch() → ()

Stops watching for game pass purchases.

Show raw api
{
    "functions": [
        {
            "name": "has",
            "desc": "Checks if a player has a game pass.\n\n```lua\nlocal hasPass = GamePass.has(player.UserId, 123456)\n```",
            "params": [
                {
                    "name": "player",
                    "desc": "The Player to check.",
                    "lua_type": "Player"
                },
                {
                    "name": "gamePassId",
                    "desc": "The game pass id to check.",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 50,
                "path": "src/GamePass/init.luau"
            }
        },
        {
            "name": "prompt",
            "desc": "Prompts the player to purchase a game pass.\n\n```lua\nGamePass.prompt(player, 123456)\n```",
            "params": [
                {
                    "name": "player",
                    "desc": "The player to prompt.",
                    "lua_type": "Player"
                },
                {
                    "name": "gamePassId",
                    "desc": "The game pass id.",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 92,
                "path": "src/GamePass/init.luau"
            }
        },
        {
            "name": "watch",
            "desc": "Watches for game pass purchases.\nThis allows the player to continue playing without having to re-join.\n\nThis is automatically called when using `GamePass.onPurchase`.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 108,
                "path": "src/GamePass/init.luau"
            }
        },
        {
            "name": "onPurchase",
            "desc": "Triggers a callback when a player purchases a game pass.\n\nThis calls `GamePass.watch` to start watching for game pass purchases.\n\nTo stop watching for game pass purchases, use `GamePass.unwatch`.\n\n```lua\nGamePass.onPurchase(function(player: Player, gamePassId: number)\n\tprint(player.Name .. \" purchased game pass \" .. gamePassId)\nend)\n```",
            "params": [
                {
                    "name": "callback",
                    "desc": "The callback to trigger.",
                    "lua_type": "Callback"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 163,
                "path": "src/GamePass/init.luau"
            }
        },
        {
            "name": "unwatch",
            "desc": "Stops watching for game pass purchases.",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 174,
                "path": "src/GamePass/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Callback",
            "desc": "",
            "lua_type": "(player: Player, gamePassId: number) -> ()",
            "source": {
                "line": 31,
                "path": "src/GamePass/init.luau"
            }
        }
    ],
    "name": "GamePass",
    "desc": "Game pass library that caches game pass ownership results and watches for pass purchases.\n\nThis module fixes the caching issue with UserOwnsGamePassAsync\nby saving purchases made in the server. This allows the user to\ncontinue playing without having to re-join.\n\n```lua\nlocal hasPass = GamePass.has(player.UserId, 123456)\n```\n\nInstall with wally by adding the following to your `wally.toml`:\n```toml\nGamePass = \"dig1t/gamepass@1.0.9\"\n```",
    "source": {
        "line": 25,
        "path": "src/GamePass/init.luau"
    }
}