What is the recommended method to access a Humanoid RootPart

Should I use:

return Character:WaitForChild("HumanoidRootPart")

Or:

local Part = Humanoid.RootPart
if Part then
	return Part
end
Humanoid:GetPropertyChangedSignal("RootPart"):Wait()
return Humanoid.RootPart

What are their pros and cons?

1 Like

Btw “RootPart” is actually “HumanoidRootPart” and it’s in the Character not the Humanoid

local Part = Character:WaitForChild("HumanoidRootPart")

RootPart is not a property of the Humanoid class. You should just use WaitForChild

Hope this helps!

1 Like

Humanoid contains a RootPart property which references HumanoidRootPart just as the PrimaryPart of the Character does. Humanoid | Documentation - Roblox Creator Hub

2 Likes

My bad, I forgot to check the documentation. You’re right.

Imo I still think WaitForChild is better because it’s only a single line of code.

But I’m not sure about the underlying process so maybe PropertyChangedSignal is way more efficient.

1 Like

There is no difference and should not be using any brain resources as a problem.

2 Likes