I am making a Battle Royale-type map in Minecraft 1.17, and trying to detect when there is only one person alive (in adventure mode) left.

Currently, I have commands to put people in spectator mode on death, and to set their score of "Alive" (z scoreboard objective) to 0 when they die. I have searched for hours, but all the solutions either don't apply to me, or use /testfor instead of the execute command.

I would love to accomplish this using scoreboard objectives or teams (preferably scores) by detecting when there is only one player with an Alive score of one, or only one player on the Alive team. There is not a set number of people who will be playing this at any given time, and there is also a "Duos" mode if anyone wants to tackle that as well.

Also, I really do not want to write (another) datapack to do this and want to use only command blocks. Sorry if this limits some of you. If there is a (really easy) way to do this with a datapack functions and you can almost do it for me, I would accept that, but I am trying to steer clear of it.

Basically, to recap, I need to detect when someone "wins". This means when there is only one player left in adventure mode. (Or one team, if you're going to help me with that too. That would be amazing.)

I now have a fake player named "Players" for the scoreboard objective "Alive", and it displays the number of people in adventure mode in the sidebar using the command: /execute store result score Players Alive if entity @e[type=minecraft:player,gamemode=adventure] in a repeating command block. Currently, that command block has a redstone output when there is at least one player in adventure mode. Changing this to be at most would be helpful. Anyone know how to do that?

You can see the sidebar and comparator lighting up because I am in adventure mode. I have tested this with two players.

I now have a way to detect when ONE person wins, (just changed adventure to !adventure in code above (1st edit)) but need a way to detect when someone wins for duos mode. Sooo.... detect when a team is out (all their members are in spectator, or when 2 players are in spectator (!adventure) on that team), and detect when there is only one team not out. So. Solved first problem, need to fix duos mode.

  • Putting this code: /testfor @p[team=alive,playercount=1] Into the execute command format would also work. I found this in my searches. Sep 15, 2021 at 21:29

1 Answer 1


Try using /execute if score in a repeating command block. Format:

/execute if score <target> <targetObjective> matches <range>

target - target player
targetObjective - the scoreboard objective used
range - integer range, you can just set this as 1

With a scoreboard objective of alive:
/execute if score Players Alive matches 1

For duos, you can match 2 in a different command block. Enable/disable which one you use with the logic that chooses solos/duos.


  • For your first response, this does not work. I have to test whether there is only one person with a score of one, not whether one specific person has a score of one. For your second one, I did not realize that playercount was a tag. How do I create that? Sep 15, 2021 at 22:10
  • @CalebStarkenburg I'm copying your tag you put in your comment. Also, the first one just executes when there's only one person with a score of 1. It doesn't matter who that person is, nor does the command ever identify that person.
    – Corsaka
    Sep 15, 2021 at 23:22
  • I don't get it, but I solved that problem. Now I need to solve duos mode. Also Edit: I didn't use that tag, I just found that code while I was searching. Sep 15, 2021 at 23:26
  • @CalebStarkenburg Updated to fit your current question. You should go back to using adventure in the original command instead of !adventure.
    – Corsaka
    Sep 15, 2021 at 23:40
  • Ok. Thank you, but the duos answer.... what if one person on each team was killed? then there are two left, and two teams left, so the command would go off before there is a winner. Sep 17, 2021 at 21:52

You must log in to answer this question.

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