Skip to main content

PlayerMockPropertyUtils

The native properties a mock stands in for, each backed by a same-named attribute. A one-element path names a Player property ("UserId"); a two-element one names a member of a client-global service ("GuiService.SelectedObject"), which the mock keeps per-mock, a headless server having one of each while a test may hold several mocks.

Members an attribute cannot hold are bridged: EnumItems round-trip through their .Name, Instances through an ObjectValue child. Paths are checked against the engine's own reflection, so a typo errors instead of reading back a value nothing will ever write.

Use PlayerMock.read, PlayerMock.write and PlayerMock.getPropertyChangedSignal.

Functions

seedProperties

PlayerMockPropertyUtils.seedProperties(
playerPlayer,--

must be a PlayerMock

overrides{[string]any}?--

Per-property seed values, keyed by property path.

) → ()

Seeds every modelled property on a fresh mock, from overrides (keyed by property path) or the pre-authored default. Paths with no default seed nothing, which is how the Instance-valued members stay nil the way a real Player's do before spawn.

Use PlayerMock.new.

read

PlayerMockPropertyUtils.read(
playerPlayer,--

must be a PlayerMock

propertyPathInstancePathTableLike--

"UserId" or "GuiService.SelectedObject"

) → any

Returns the seeded backing attribute, or the pre-authored default when unset.

Use PlayerMock.read.

write

PlayerMockPropertyUtils.write(
playerPlayer,--

must be a PlayerMock

propertyPathInstancePathTableLike,--

"UserId" or "GuiService.SelectedObject"

valueany
) → ()

Writing Character = nil carries the engine's despawn semantics.

Use PlayerMock.write.

getPropertyChangedSignal

PlayerMockPropertyUtils.getPropertyChangedSignal(
playerPlayer,--

must be a PlayerMock

propertyPathInstancePathTableLike--

"UserId" or "GuiService.SelectedObject"

) → RBXScriptSignal

Returns the backing attribute's changed signal, or the backing ObjectValue's Value-changed signal for Instance-valued members.

Use PlayerMock.getPropertyChangedSignal.

Show raw api
{
    "functions": [
        {
            "name": "seedProperties",
            "desc": "Seeds every modelled property on a fresh mock, from `overrides` (keyed by property path) or the\npre-authored default. Paths with no default seed nothing, which is how the Instance-valued members\nstay nil the way a real `Player`'s do before spawn.\n\nUse [PlayerMock.new].",
            "params": [
                {
                    "name": "player",
                    "desc": "must be a PlayerMock",
                    "lua_type": "Player"
                },
                {
                    "name": "overrides",
                    "desc": "Per-property seed values, keyed by property path.",
                    "lua_type": "{ [string]: any }?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 72,
                "path": "src/player-mock/src/Shared/Helpers/Properties/PlayerMockPropertyUtils.lua"
            }
        },
        {
            "name": "read",
            "desc": "Returns the seeded backing attribute, or the pre-authored default when unset.\n\nUse [PlayerMock.read].",
            "params": [
                {
                    "name": "player",
                    "desc": "must be a PlayerMock",
                    "lua_type": "Player"
                },
                {
                    "name": "propertyPath",
                    "desc": "`\"UserId\"` or `\"GuiService.SelectedObject\"`",
                    "lua_type": "InstancePathTableLike"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 99,
                "path": "src/player-mock/src/Shared/Helpers/Properties/PlayerMockPropertyUtils.lua"
            }
        },
        {
            "name": "write",
            "desc": "Writing `Character = nil` carries the engine's despawn semantics.\n\nUse [PlayerMock.write].",
            "params": [
                {
                    "name": "player",
                    "desc": "must be a PlayerMock",
                    "lua_type": "Player"
                },
                {
                    "name": "propertyPath",
                    "desc": "`\"UserId\"` or `\"GuiService.SelectedObject\"`",
                    "lua_type": "InstancePathTableLike"
                },
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 133,
                "path": "src/player-mock/src/Shared/Helpers/Properties/PlayerMockPropertyUtils.lua"
            }
        },
        {
            "name": "getPropertyChangedSignal",
            "desc": "Returns the backing attribute's changed signal, or the backing ObjectValue's Value-changed signal\nfor Instance-valued members.\n\nUse [PlayerMock.getPropertyChangedSignal].",
            "params": [
                {
                    "name": "player",
                    "desc": "must be a PlayerMock",
                    "lua_type": "Player"
                },
                {
                    "name": "propertyPath",
                    "desc": "`\"UserId\"` or `\"GuiService.SelectedObject\"`",
                    "lua_type": "InstancePathTableLike"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "RBXScriptSignal"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 183,
                "path": "src/player-mock/src/Shared/Helpers/Properties/PlayerMockPropertyUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "PlayerMockPropertyUtils",
    "desc": "The native properties a mock stands in for, each backed by a same-named attribute. A one-element\npath names a `Player` property (`\"UserId\"`); a two-element one names a member of a client-global\nservice (`\"GuiService.SelectedObject\"`), which the mock keeps per-mock, a headless server having\none of each while a test may hold several mocks.\n\nMembers an attribute cannot hold are bridged: EnumItems round-trip through their `.Name`,\nInstances through an ObjectValue child. Paths are checked against the engine's own reflection, so\na typo errors instead of reading back a value nothing will ever write.\n\nUse [PlayerMock.read], [PlayerMock.write] and [PlayerMock.getPropertyChangedSignal].",
    "source": {
        "line": 16,
        "path": "src/player-mock/src/Shared/Helpers/Properties/PlayerMockPropertyUtils.lua"
    }
}