Skip to main content

PlayerGuiUtils

Helper methods for finding and retrieving the PlayerGui instance

Functions

getPlayerGui

PlayerGuiUtils.getPlayerGui() → PlayerGui

Finds the current player gui for the Players.LocalPlayer property or errors.

WARNING

This method errors if it can't find the PlayerGui. Fortunately, the PlayerGui is pretty much guaranteed to exist in most scenarios.

findPlayerGui

PlayerGuiUtils.findPlayerGui() → PlayerGui | nil

Finds the current player gui for the Players.LocalPlayer property.

observePlayerGui

PlayerGuiUtils.observePlayerGui() → Observable<PlayerGui | nil>

Observes the current player gui. On a real client this is static -- the engine inserts the PlayerGui before any client script runs and never replaces it. Headless (no Players.LocalPlayer) it follows the PlayerMock local-player designation, which a test may make or change after subscription (see PlayerMock.setMockedLocalPlayer).

Show raw api
{
    "functions": [
        {
            "name": "getPlayerGui",
            "desc": "Finds the current player gui for the [Players.LocalPlayer] property or errors.\n\n:::warning\nThis method errors if it can't find the PlayerGui. Fortunately, the PlayerGui is pretty much\nguaranteed to exist in most scenarios.\n:::",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "PlayerGui"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 28,
                "path": "src/uiobjectutils/src/Client/PlayerGuiUtils.lua"
            }
        },
        {
            "name": "findPlayerGui",
            "desc": "Finds the current player gui for the [Players.LocalPlayer] property.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "PlayerGui | nil"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 51,
                "path": "src/uiobjectutils/src/Client/PlayerGuiUtils.lua"
            }
        },
        {
            "name": "observePlayerGui",
            "desc": "Observes the current player gui. On a real client this is static -- the engine inserts the\nPlayerGui before any client script runs and never replaces it. Headless (no `Players.LocalPlayer`)\nit follows the [PlayerMock] local-player designation, which a test may make or change after\nsubscription (see [PlayerMock.setMockedLocalPlayer]).",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<PlayerGui | nil>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 72,
                "path": "src/uiobjectutils/src/Client/PlayerGuiUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "PlayerGuiUtils",
    "desc": "Helper methods for finding and retrieving the [PlayerGui] instance",
    "source": {
        "line": 6,
        "path": "src/uiobjectutils/src/Client/PlayerGuiUtils.lua"
    }
}