I have a custom animation script that uses Humanoid.Running, but the issue here is it doesn’t work while the player is in the air/floating. What’s a way I can check if the player is moving even while floating?
The Humanoid has a property called MoveDirection which determines, as a unit vector, the direction a player is moving in. You can access the Magnitude property and see if it’s greater than 0 to know if there is active movement without relying on what their HumanoidStateType is.
Refer to the code sample on the page.
Can this help with jumping or freefalling?
Not sure what you mean to ask there. Are you asking if this can help determine the direction a player is moving in while they’re in an airborne state? Answer is no then, because MoveDirection only describes the movement along a 2D XZ axis (Y is not applicable to MoveDirection). You’ll have to find a different property if you need to work with 3D movement where Y is a value that changes.
You can also intercept when the MoveDirection
property changes:
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
print(Humanoid.MoveDirection)
end)
you should do print(Humanoid.MoveDirection.Magnitude)
there are more states for this:
How do you make it so that if the player moves, ONLY the player who moved, it happens to the player that moves specific things