Skip to main content

PlayerMockPlayerServiceUtils

The mock's stand-ins for what the Players service answers: which mock is the local player, and which mock a userId resolves to. The local-player designation is a tag on the mock itself rather than Lua module state, so a destroyed mock takes it along.

Use PlayerMock.setMockedLocalPlayer, PlayerMock.getMockedLocalPlayer and PlayerMock.getMockByUserId.

Functions

getPlayerByUserId

PlayerMockPlayerServiceUtils.getPlayerByUserId(userIdnumber) → Player?

Returns the mock in the DataModel whose UserId stand-in matches, or nil. The mock counterpart of Players:GetPlayerByUserId. Real UserIds are unique; seed mocks the same way, since the first match wins.

Use PlayerMock.getMockByUserId.

setMockedLocalPlayer

PlayerMockPlayerServiceUtils.setMockedLocalPlayer(
playerPlayer?--

must be a PlayerMock in the DataModel, or nil to clear

) → () → ()--

Restores the previous designation. Safe to call more than once.

Returns the disposer that restores the previous designation.

Use PlayerMock.setMockedLocalPlayer.

Show raw api
{
    "functions": [
        {
            "name": "getPlayerByUserId",
            "desc": "Returns the mock in the DataModel whose `UserId` stand-in matches, or nil. The mock counterpart of\n`Players:GetPlayerByUserId`. Real UserIds are unique; seed mocks the same way, since the first\nmatch wins.\n\nUse [PlayerMock.getMockByUserId].",
            "params": [
                {
                    "name": "userId",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Player?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 33,
                "path": "src/player-mock/src/Shared/Helpers/Services/PlayerMockPlayerServiceUtils.lua"
            }
        },
        {
            "name": "setMockedLocalPlayer",
            "desc": "Returns the disposer that restores the previous designation.\n\nUse [PlayerMock.setMockedLocalPlayer].",
            "params": [
                {
                    "name": "player",
                    "desc": "must be a PlayerMock in the DataModel, or nil to clear",
                    "lua_type": "Player?"
                }
            ],
            "returns": [
                {
                    "desc": "Restores the previous designation. Safe to call more than once.",
                    "lua_type": "() -> ()"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 56,
                "path": "src/player-mock/src/Shared/Helpers/Services/PlayerMockPlayerServiceUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "PlayerMockPlayerServiceUtils",
    "desc": "The mock's stand-ins for what the `Players` service answers: which mock is the local player, and\nwhich mock a userId resolves to. The local-player designation is a tag on the mock itself rather\nthan Lua module state, so a destroyed mock takes it along.\n\nUse [PlayerMock.setMockedLocalPlayer], [PlayerMock.getMockedLocalPlayer] and\n[PlayerMock.getMockByUserId].",
    "source": {
        "line": 12,
        "path": "src/player-mock/src/Shared/Helpers/Services/PlayerMockPlayerServiceUtils.lua"
    }
}