Best way to detect if a Player IS moving

Using Humanoid.MoveDirection and Humanoid.Running doesn’t work

Humanoid.Running only fires when the Speed changes

Using Humanoid:GetPropertyChangesSignal(“MoveDirection”) also doesn’t work because it only fires when the “MoveDirection” changes… it seems like my only option is to use a Heartbeat connection or Bind to Renderstepped in which I would like to avoid if possible

Is there a better way to detect if a player is moving? I would prefer not to check every Frame (60 times per second) that is just too much.


Use case:

  • Goal: I want an animation that is currently playing to stop if the player moves

  • Current issue: If a player is already moving and then play that animation it will not be canceled

I was looking into using the default PlayerControl script but I couldn’t find any “signal” for detecting if the player is moving or not.

3 Likes

Does the Velocity of the humanoidrootpart work for what you’re doing?

2 Likes

Wouldn’t it be best to set the Animation Priority to Core if it isn’t already, this would allow the animation to stop if the character is moved?

1 Like

@desinied , no the idle animation would play over it afaik, I could be wrong though, but I would prefer to have the Animation’s Priority set to Action


@yehhhhhhhhh111 No Velocity doesn’t change if you move in the same direction.

It also can’t be used with .Changed nor :GetPropertyChangedSignal

1 Like

You could check Humanoid.MoveDirection
Humanoid.MoveDirection -- Returns 0,0,0 if not moving according to user inputs , if its not 0,0,0 it indicates that the player is moving

7 Likes

MoveDirection should work for this, back when I first started scripting a wrote a scuff script to detect when they start moving.

coroutine.wrap(function()
while wait() do
	if  humanoid.MoveDirection.X > 0 or humanoid.MoveDirection.X < 0 or humanoid.MoveDirection.Z > 0 or humanoid.MoveDirection.Z < 0 or humanoid.MoveDirection.Y > 0 or humanoid.MoveDirection.Y < 0   then -- as you can see it's scuff since I didn't know what I was doing much back then
-- Stop animation
end		
end
		end)()

4 Likes

Thats some quite big if condition, I would ask the person to use Humanoid.MoveDirection ~= Vector3.one since its much shorter and works perfectly.

9 Likes

Yeah, I just saw your post, again I got that line a code from a script a year ago. either way both work.

1 Like

Oh right, I forgot.

If could just check if the player is moving then don’t play the animation in the first place.

Thanks for the suggestion @Razor_IB @StraightScared