My title almost explains everything I want to do. I want the player to press a button. Then the player gets an item from that but the player is only allowed to have the item for a minute, so I need some time delay of 60 seconds without redstone before I execute the command that gets rid of the item. Also I want the player to be able to see how much time he has left and this command has to work for only the person who was closest to the button when executed but might not be the closest anymore when the timer runs out. Anny suggestions?


1 Answer 1


Sure, here you go:

Add a scoreboard objective to hold the timer before you start.

scoreboard objectives add timer dummy [{"text":"Time"}]

When the button is pressed, run these commands to set their timer score to 1200. Because there are 20 ticks per second, 1200 ticks is 60 seconds. Then, give them the item with a custom tag so that it can be recognized for removing:

scoreboard players set @p timer 1200
give @p minecraft:tripwire_hook{udt:{FinishKey:1b}}

(I personally use udt:{} to surround all user-defined tags)

Somewhere in your world, have a command machine that runs the following commands in order:

  1. /scoreboard players remove @a[scores={timer=1..}] timer 1
    Tell all players with a timer of more than 0 to remove 1 from their score.
  2. /title @a[scores={timer=0..}] actionbar [{"score":{"name":"*","objective":"timer"}}]
    Title all players with their timer score. This will display the number of ticks remaining.
  3. /clear @a[scores={timer=0}] minecraft:tripwire_hook{udt:{FinishKey:1b}}
    Clear all players with timer 0 from the item.
  4. /scoreboard players reset @a[scores={timer=0}]
    Get rid of the scores of the players' whose time is up.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .