How to detect if a player is standing still?

I’m trying to play certain animations when the player hasn’t been doing anything for about a minute,
but I can’t find a proper way to detect this player behaviour.
There doesn’t seem to be any statetype that fires an event for this either, so that makes things more complicated.

Is there perhaps any other method to do this, or will I need to make a workaround?

5 Likes

Humanoid Move Direction equals 0,0,0 means the humanoid is standing still.
https://wiki.roblox.com/index.php?title=API:Class/Humanoid/MoveDirection

9 Likes

I do not believe there is an event for this, I do know that the BasePart class offers a Velocity argument. If you do a while loop and constantly check this variable, perhaps you can play the animation that way.

For example, this could work:

while true do
	if player.Character.Torso.Velocity < 5 then
		-- play animation
	end
	wait()
end
1 Like

I didn’t know that, thanks! That might just turn out to be useful.

While that is a possible fix, I’d rather not have a while loop run most of the time.
However, checking for the player’s velocity is also a good one to consider. Thanks!

I mean you could always use the GetPropertyChangedSignal event on your part for the velocity like so. You can even do that with Smellysuperfart’s answer. :slight_smile:

player.Character.Torso:GetPropertyChangedSignal('Velocity'):Connect(function()
	if player.Character.Torso.Velocity < 5 then
		-- play animation
	end
end)

Happy scripting!

12 Likes

Unfortunately that would not work on mobile and Xbox because you can walk less than 5 studs per second due to the sensitivity of the joystick. So I would say the best method is to check the MoveDirection.

2 Likes

Then it would be better to go with @Smellysuperfart 's idea, and using that in @ShardItem 's solution.
It seems to work perfectly fine so far!

4 Likes