Skip to main content

PlayerUtils

Provides utility functions for working with players.

Functions

OnPlayerAdded

PlayerUtils:OnPlayerAdded(
callbackfunction,--

The callback to invoke when a player joins

callbackNamestring?--

The name of the callback (optional)

) → ()

Add a callback for any player, existing and future, that joins.

PlayerUtils:OnPlayerAdded(function(player, playerMaid)
	print(`Hello, {player.Name}!`)
end, "CallbackName")

RemoveJoinCallback

PlayerUtils:RemoveJoinCallback(
callbackNamestring--

The name of the callback to remove

) → ()

Remove a spawn callback by name.

PlayerUtils:RemoveJoinCallback("CallbackName")

GetPlayerMaid

PlayerUtils:GetPlayerMaid(
playerPlayer--

The player to get the maid for

) → Maid--

The PlayerMaid for the player

Returns the maid associated with a specific player, which cleans up when the player disconnects.

FetchUserInfo

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
PlayerUtils:FetchUserInfo(
userIdnumber--

The UserId to get the user info from

) → UserInfo?--

The user's info

Types

interface UserInfo {
Idnumber
Usernamestring
DisplayNamestring
HasVerifiedBadgeboolean
}

Fetch the user info for the user with the specified UserId from the Roblox website.

Show raw api
{
    "functions": [
        {
            "name": "OnPlayerAdded",
            "desc": "Add a callback for any player, existing and future, that joins.\n\n```lua\nPlayerUtils:OnPlayerAdded(function(player, playerMaid)\n\tprint(`Hello, {player.Name}!`)\nend, \"CallbackName\")\n```",
            "params": [
                {
                    "name": "callback",
                    "desc": "The callback to invoke when a player joins",
                    "lua_type": "function"
                },
                {
                    "name": "callbackName",
                    "desc": "The name of the callback (optional)",
                    "lua_type": "string?"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 68,
                "path": "src/shared/core/tasks/PlayerUtils.luau"
            }
        },
        {
            "name": "RemoveJoinCallback",
            "desc": "Remove a spawn callback by name.\n\n```lua\nPlayerUtils:RemoveJoinCallback(\"CallbackName\")\n```",
            "params": [
                {
                    "name": "callbackName",
                    "desc": "The name of the callback to remove",
                    "lua_type": "string"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 91,
                "path": "src/shared/core/tasks/PlayerUtils.luau"
            }
        },
        {
            "name": "GetPlayerMaid",
            "desc": "Returns the maid associated with a specific player, which cleans up\nwhen the player disconnects.",
            "params": [
                {
                    "name": "player",
                    "desc": "The player to get the maid for",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "The PlayerMaid for the player",
                    "lua_type": "Maid"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 106,
                "path": "src/shared/core/tasks/PlayerUtils.luau"
            }
        },
        {
            "name": "FetchUserInfo",
            "desc": "Fetch the user info for the user with the specified UserId from the\nRoblox website.",
            "params": [
                {
                    "name": "userId",
                    "desc": "The UserId to get the user info from",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "The user's info",
                    "lua_type": "UserInfo?"
                }
            ],
            "function_type": "method",
            "yields": true,
            "source": {
                "line": 124,
                "path": "src/shared/core/tasks/PlayerUtils.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "UserInfo",
            "desc": "",
            "fields": [
                {
                    "name": "Id",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "Username",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "DisplayName",
                    "lua_type": "string",
                    "desc": ""
                },
                {
                    "name": "HasVerifiedBadge",
                    "lua_type": "boolean",
                    "desc": ""
                }
            ],
            "source": {
                "line": 37,
                "path": "src/shared/core/tasks/PlayerUtils.luau"
            }
        }
    ],
    "name": "PlayerUtils",
    "desc": "Provides utility functions for working with players.",
    "source": {
        "line": 14,
        "path": "src/shared/core/tasks/PlayerUtils.luau"
    }
}