Checking if player is standing still

Hi! My goal is to play animation while player is standing still. Here is a code I wrote:

local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
humanoid:GetPropertyChangedSignal('MoveDirection'):Connect(function()
	       		print("I am moving around")
				if humanoid.MoveDirection.Magnitude == 0 then
					print("I am standing")
				end
			end)	

This code works but my output is going crazy! That’s why I am not sure if that’s the most efficient way to do it. (correct me if I am wrong)

Here are things I have already tried:

  • Detecting the change of Velocity in player’s UpperTorso (didn’t detect a change)
  • Detecting Humanoid:StateChange() (came to conclusion that there is no state for standing still, defoult state is running)
    Thanks!
1 Like

you could try utilizing Humanoid.Running, if you needed to know when they stopped walking/running:

Humanoid.Running:Connect(function(speed)
    if speed == 0 then
     	print("I am standing")
    end
 end)

You can also try using Humanoid:GetState() to check if the player isn’t jumping or free-falling, for example:

Humanoid.Running:Connect(function(speed)
	local State = Humanoid:GetState()
	      if (State ~=Enum.HumanoidStateType.Freefall) and (State ~=Enum.HumanoidStateType.Jumping) then
		      if speed == 0 then
        	print("I am standing")
        end
    end
 end)
11 Likes