Arqade Asked by JovadaPlayz on November 30, 2020
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?
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:
/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./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./clear @a[scores={timer=0}] minecraft:tripwire_hook{udt:{FinishKey:1b}}
Clear all players with timer 0 from the item./scoreboard players reset @a[scores={timer=0}]
Get rid of the scores of the players' whose time is up.Answered by ExpertCoder14 on November 30, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP