Is there a away to test if a player isn't moving?

At the moment I have put this command on a hopper clock:

/scoreboard players set @a sneak 3 

But that doesn't seem to work because in another command block I am testing for a score of three, and every tick it summons a block even when you're moving.

I am using this for a vanilla block hunt so when your not moving you become a solid block.


@132ikl's answer works in general, but there is a flaw to the design: stat.walkOneCm does not increase while you are in mid-air. We can fix this by assuming every player that is in mid-air is moving.

Create the scoreboard:

/scoreboard objectives add Moving stat.walkOneCm

Create a 20Hz clock or use repeat/chain command blocks and run the following two commands:

/scoreboard players remove @a[score_Moving_min=1] Moving 1 {OnGround:1b}
/scoreboard players set @a[score_Moving_min=1] Moving 1

The first command will reduce the Moving score by one for every player on the ground, if it is at least 1 (I.e. the score will not go below 0).
The second command limits the Moving score to at most 1 by setting it to one if it is greater.

Moving will be 1 for people that are moving, or were moving prior to jumping (jumping in place does not work), and 0 otherwise.


Step 1: Create two scoreboards:

/scoreboard objectives add walk stat.walkOneCm  
/scoreboard objectives add moving dummy

Step 2: Make a command block clock with these commands:

/scoreboard players set @a walk 0
/scoreboard players set @a[score_walk_min=1] moving 1

Then everyone that is not walking will have a moving score of 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy