Skip to main content

RootPartUtils

Utility functions involving the root part

Functions

promiseRootPart

RootPartUtils.promiseRootPart(humanoidHumanoid) → Promise<BasePart>

Given a humanoid creates a promise that will resolve once the Humanoid.RootPart property resolves properly.

INFO

This works around the fact that humanoid:GetPropertyChangedSignal("RootPart") does not fire when the rootpart changes on a humanoid.

promisePlayerHumanoidRootPart

RootPartUtils.promisePlayerHumanoidRootPart(playerPlayer) → Promise<BasePart>

Given a player creates a promise that will resolve once the player has a character whose humanoid has a resolved Humanoid.RootPart.

Resolves with the root part of whatever character the player has at that moment, so a respawn while waiting is followed instead of leaving the promise stuck on a destroyed character. Health is not considered -- a dead humanoid still has a root part, matching CharacterUtils.getPlayerRootPart.

RootPartUtils.promisePlayerHumanoidRootPart(player):Then(function(rootPart)
	print(rootPart:GetPivot())
end)

Accepts a PlayerMock as well as a real Player.

getPlayerRootPart

RootPartUtils.getPlayerRootPart(playerPlayer) → BasePart?--

Nil if not found

Gets the root part of the player's current character, if it exists.

Synchronous counterpart to RootPartUtils.promisePlayerHumanoidRootPart. Health is not considered -- a dead humanoid still has a root part.

local rootPart = RootPartUtils.getPlayerRootPart(player)
if rootPart then
	print(rootPart:GetPivot())
end

Accepts a PlayerMock as well as a real Player.

getRootPart

RootPartUtils.getRootPart(characterModel) → BasePart?--

Nil if not found

Gets the root part of a character, if it exists

Show raw api
{
    "functions": [
        {
            "name": "promiseRootPart",
            "desc": "Given a humanoid creates a promise that will resolve once the `Humanoid.RootPart` property\nresolves properly.\n\n:::info\nThis works around the fact that `humanoid:GetPropertyChangedSignal(\"RootPart\")` does not fire\nwhen the rootpart changes on a humanoid.\n:::",
            "params": [
                {
                    "name": "humanoid",
                    "desc": "",
                    "lua_type": "Humanoid"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<BasePart>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 30,
                "path": "src/characterutils/src/Shared/RootPartUtils.lua"
            }
        },
        {
            "name": "promisePlayerHumanoidRootPart",
            "desc": "Given a player creates a promise that will resolve once the player has a character whose\nhumanoid has a resolved `Humanoid.RootPart`.\n\nResolves with the root part of whatever character the player has at that moment, so a respawn\nwhile waiting is followed instead of leaving the promise stuck on a destroyed character. Health\nis not considered -- a dead humanoid still has a root part, matching\n[CharacterUtils.getPlayerRootPart].\n\n```lua\nRootPartUtils.promisePlayerHumanoidRootPart(player):Then(function(rootPart)\n\tprint(rootPart:GetPivot())\nend)\n```\n\nAccepts a [PlayerMock] as well as a real `Player`.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<BasePart>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 95,
                "path": "src/characterutils/src/Shared/RootPartUtils.lua"
            }
        },
        {
            "name": "getPlayerRootPart",
            "desc": "Gets the root part of the player's current character, if it exists.\n\nSynchronous counterpart to [RootPartUtils.promisePlayerHumanoidRootPart]. Health is not\nconsidered -- a dead humanoid still has a root part.\n\n```lua\nlocal rootPart = RootPartUtils.getPlayerRootPart(player)\nif rootPart then\n\tprint(rootPart:GetPivot())\nend\n```\n\nAccepts a [PlayerMock] as well as a real `Player`.",
            "params": [
                {
                    "name": "player",
                    "desc": "",
                    "lua_type": "Player"
                }
            ],
            "returns": [
                {
                    "desc": "Nil if not found",
                    "lua_type": "BasePart?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 161,
                "path": "src/characterutils/src/Shared/RootPartUtils.lua"
            }
        },
        {
            "name": "getRootPart",
            "desc": "Gets the root part of a character, if it exists",
            "params": [
                {
                    "name": "character",
                    "desc": "",
                    "lua_type": "Model"
                }
            ],
            "returns": [
                {
                    "desc": "Nil if not found",
                    "lua_type": "BasePart?"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 172,
                "path": "src/characterutils/src/Shared/RootPartUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "RootPartUtils",
    "desc": "Utility functions involving the root part",
    "source": {
        "line": 6,
        "path": "src/characterutils/src/Shared/RootPartUtils.lua"
    }
}