Connect to Humanoid.RootPart a function

Similar to Script.Parent:GetChildren().Changed?,
using the root in particular: Humanoid | Documentation - Roblox Creator Hub.

As soon as the HumanoidRootPart is added I want to run some code relative to it. Through the reference of Humanoid.RootPart to be independent of custom character problems/ renamed HRPs.

How do I approach this? Using a signal for a particular parameter of Humanoid? Implementation appreciated.

1 Like

I believe you are going to have to use ChildAdded on your character in order to fire a function when the HRP is added.

Not really sure if you’re looking for this type of answer, but you could do something like this:

For server-sided, which is less precise:

repeat wait() until yourCharacter:FindFirstChild('HumanoidRootPart')
-- your code here, it will fire once when the HumanoidRootPart is found within the character

For client-sided which is pretty much the most precise you can get, IIRC, it checks 60 times per second:

local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
repeat game:GetService('RunService').RenderStepped:Wait() until character:FindFirstChild('HumanoidRootPart')
-- same principle as above, it will fire once HumanoidRootPart is found within the character model.