How do I set up a delay within a command block [closed]
I'm trying to recreate Runner in Minecraft 1.9 singleplayer, but I cannot get how to set up a delay so that the player can run without getting killed.
Best Answer
Add an scoreboard objective:
/scoreboard objectives add Moving stat.walkOneCm
Run the following commands in a clock(in exactly that order):
/kill @a[score_Moving=0,m=!1]
/scoreboard players set @a Moving 0
Warning: Be careful when setting this up. You will get killed, when not walking/running. And when the machine is killing you the whole time, you have no chance to disable it(except for external tools).
Pictures about "How do I set up a delay within a command block [closed]"
![How do I set up a delay within a command block [closed] - Closeup of wooden blocks placed on top of each other for playing board game How do I set up a delay within a command block [closed] - Closeup of wooden blocks placed on top of each other for playing board game](/assets/images/how_do_i_set_up_a_delay_within_a_command_block_closed_1.jpeg)
![How do I set up a delay within a command block [closed] - Close-up of a Solid Concrete Block How do I set up a delay within a command block [closed] - Close-up of a Solid Concrete Block](/assets/images/how_do_i_set_up_a_delay_within_a_command_block_closed_2.jpeg)
![How do I set up a delay within a command block [closed] - Set of shiny transparent amethysts grown together How do I set up a delay within a command block [closed] - Set of shiny transparent amethysts grown together](/assets/images/how_do_i_set_up_a_delay_within_a_command_block_closed_3.jpeg)
How do you put a delay in a command block?
Replace {delay} with the delay you want in ticks, plus one. For example, if you want a delay of 5 seconds, you would put 101 there since 5sec * 20 tick/sec + 1 = 101 . Replace {entity} with the selector for the entity that you want to run the command.How do you make a command delay?
In Bedrock Edition, it can also delay before executing commands if "Delay in Ticks" is not 0: When it is triggered, If it has been activated, the chain command block checks whether the command block behind it has executed successfully (if in conditional mode), then it delays.How To Delay Minecraft Commands Simple (No Scoreboards)
More answers regarding how do I set up a delay within a command block [closed]
Answer 2
I think what you want is a "grace period" for not running? I.e. the command blocks kill you if you stand still for more than, say, a second?
If so, you can run these in a repeat/chain setup:
/scoreboard players set @a OnGround 0 {OnGround:0b}
/scoreboard players set @a OnGround 1 {OnGround:1b}
/scoreboard players remove @a[score_Moving_min=1] Moving 1
/scoreboard players set @a[score_Moving_min=20] Moving 20
/kill @a[score_Moving=0,score_OnGround_min=1,tag=Running]
/scoreboard players tag @a[score_Moving=0,score_OnGround_min=1,tag=Running] remove Running
Moving is a stat.walkOneCm type objective, the OnGround tag is dummy. Moving does not increase while jumping/falling, which makes this addition necessary or else jumping or falling could kill you. The Running tag is to prevent an endless kill loop, add it to anyone that has to run to not die.
To adjust the timing, adjust the score set in the second command (both in the target selector and the set command) to the number of ticks the player may stand still (20 ticks = 1 second). This command acts like a "hard cap" on the Moving score (it can never exceed the value given).
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Joshua Miranda, Joshua Miranda, Lucas VinÃcius Pontes, Karolina Grabowska
