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?
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?
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!
Humanoid
contains a RootPart
property which references HumanoidRootPart
just as the PrimaryPart
of the Character does. Humanoid | Documentation - Roblox Creator Hub
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.
There is no difference and should not be using any brain resources as a problem.