Run command after 60 seconds + display timer for individual player when player presses button
Solution 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:
-
Tell all players with a timer of more than 0 to remove 1 from their score./scoreboard players remove @a[scores={timer=1..}] timer 1
-
Title all players with their timer score. This will display the number of ticks remaining./title @a[scores={timer=0..}] actionbar [{"score":{"name":"*","objective":"timer"}}]
-
Clear all players with timer 0 from the item./clear @a[scores={timer=0}] minecraft:tripwire_hook{udt:{FinishKey:1b}}
-
Get rid of the scores of the players' whose time is up./scoreboard players reset @a[scores={timer=0}]