0

Im trying to make a world where survivors have to live for 5 minutes, or the "Hunter" has to kill all the survivors within 5 minutes. Im using an xp timer for the clock, so all im stumped on is how to check when the there is only one player left (the hunter).

1

How to Strictly Detect Number Returned by Target Selector

This would be possible in Java Edition 1.13+, by storing the number in a scoreboard value and testing it for a specific number. But in Bedrock Edition, so far, I only can test for presence or absence, not a specific number.
Commands in Bedrock Edition are quite limited. One way I could think of is using a redstone comparator coming out of the command block, which will light up a redstone signal equal to the number of players detected, but that comes with further side effects, such as only being able to detect up to 15 players.

That said, there may be an obscure way to accomplish your task, but I’m not the best at advanced command use in BE. If you have found a way, please post an answer! Both me and the OP would be delighted to see it.

| improve this answer | |
  • I found a way! you can use a reverse circuit. Here's how: Repeating Command Block : /testfor @a [scores={objectivename}] then run a comparator from the block, 1 redstone dust and then attach it to a block with a redstone torch on it, for a reverse circuit, then the following command blocks should do your desired function when there is only one remaining player on your objective list. – Just a gamer Jun 26 at 22:12
  • If you run two pieces of redstone dust from the comparator before inverting it with the redstone torch, then the torch turns on when there are 1 or 0 players left. – ExpertCoder14 Jun 26 at 22:19
  • i was trying to edit it to 0, but what i did is gave the hunter a 0 value, instead of 1, in the pregame. so when everyone else is dead, teleporting them to a room that gives a 0 value, when there are no more 1 values (all dead or hunter) the hunter wins. thank you for giving me the idea of the comparator! – Just a gamer Jun 26 at 22:44
  • @Justagamer Where did you give people 0-1 values? Using a scoreboard objective? – ExpertCoder14 Jun 26 at 22:48
  • yes! my setup is, when a new game is started, it wipes the scoreboard completely, like removes the objective and everything. it re-adds the scoreboard, then everyone in the lobby, to avoid the Player Offline tag on the scoreboard, and if you are the hunter for the game you get taken to an intermission room for 15 seconds while the survivors run around the map. here, your value is reset to 0, and when you die to the hunter, you get sent to a "dead" room where you can spectate, and your value is also reduced to 0. now all i need to know is how to detect when someone has a sword on them. – Just a gamer Jun 26 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.