RootPartUtils
Utility functions involving the root part
Functions
promiseRootPart
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
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
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
Gets the root part of a character, if it exists