Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to know if a humanoid is idle?

2 answers

Although the HumanoidStateType Enum does not provide developers with any information regarding the idle state of a Humanoid (which it really should), there is another way to determine whether a Humanoid is idle or not, and that is through the MoveDirection property of the Humanoid object.

What this read-only property does is return the Vector3 direction that the player is moving towards. Knowing this, we can conclude that when the player is idle, its MoveDirection will be 0 in all directions. However, if the Humanoid is only jumping or falling but not moving, then its MoveDirection is still 0 in every direction. Thus, we can do something like this in our code:

if humanoid.MoveDirection == Vector3.new(0, 0, 0) 
and humanoid:GetState() ~= Enum.HumanoidStateType.Jumping 
and humanoid:GetState() ~= Enum.HumanoidStateType.FreeFall then
	-- humanoid is idle
end

1 comment

0

Great answer!

This discussion is preserved as it was. New answers, comments, and votes are closed.