2

I'm working on a mini-game that requires lives. I set up the scoreboards that show the lives on the sidebar, as shown here -enter image description here

I set up that board by adding a deathcount objective and then dummied it by adding a dummy objective for it that replaces it on the sidebar. I want to find out how to made that number decrease for any player that has died. Also I would like to how to put a player into spectator mode a player reaches zero "lives."

These are the scoreboard commands (in order) that sets them up.

scoreboard objectives add Deaths deathCount
scoreboard objectives add Lives dummy
scoreboard objectives setdisplay sidebar Lives
scoreboard players set @a Lives 5

1 Answer 1

1

First, add the lives count objective (for display) and the death count objective (for behind the scenes):

/scoreboard objectives add lives dummy Lives
/scoreboard objectives add deaths Deathcount

Then wire these up to a redstone clock:

/scoreboard scoreboard players set * lives 5
/scoreboard players operation @a lives -= @a deaths
/gamemode 3 @a[score_deaths_min=5]
/scoreboard players set @a[playerGameType=3] deaths 0

Make sure the first two lines are executed in that order, otherwise players will always have what looks like 5 lives.
Note: I have not tested this, so there are probably some bugs in it.

Lives will then be the number of lives remaining, which you can display wherever you want to.

6
  • Why do I have to wire /scoreboard scoreboard players set * lives 5 to a clock? Wouldn't that keep giving lives to the player? Commented Aug 8, 2014 at 1:05
  • @TechnoSlamm Yes, but then it immediately goes back down because of the next line Commented Aug 8, 2014 at 1:16
  • I tried it and still having trouble. Thanks for replying though! Commented Aug 8, 2014 at 1:27
  • @TechnoSlamm What troubles are you having? Commented Aug 8, 2014 at 1:47
  • It doesn't work... Commented Aug 8, 2014 at 20:02

You must log in to answer this question.

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