2

How do I detect if only one player is on a specific team

colind8's Avatar colind85/31/19 4:46 pm
2 emeralds 2.6k 1
6/1/2019 10:21 pm
Cadermate's Avatar Cadermate
I'm trying to make a Minecraft Spleef minigame sort of thing and my redstone currently goes like this:


1. When the start button is pressed, the map clears, all the players get spread out, all the players get added to the team 'player', and the game begins. Once a player dies, they're added to a team called 'dead'.

2. This is the part I'm confused at. Here, I want to execute a command if exactly one player is on the team 'player'. I do not know how to do this.

3. Once the check is complete, it will teleport everyone back to a lobby and clear inventories.

So basically, I need to know how to run a command if only one person is on the team 'player'. Thanks.
Posted by colind8's Avatar
colind8
Level 1 : New Crafter
0

Create an account or sign in to comment.

1

3
06/01/2019 10:21 pmhistory
Level 16 : Journeyman Engineer
Cadermate
Cadermate's Avatar
The setup for this requires the use of a few more commands.

First, setup a scoreboard to keep track of how many players are on a team at a given time.
/scoreboard objectives add playerCount dummy

Then, on a repeating command block, store the result of the list of the players on the team to the scoreboard.
/execute store score players playerCount run team list player

Finally, run the command on a repeating command block to test for only one player on a team.
/execute if score players playerCount matches 1 run [Your tp command here]The setup for this requires the use of a few more commands.

First, setup a scoreboard to keep track of how many players are on a team at a given time.
/scoreboard objectives add playerCount dummy

Then, on a repeating command block, store the result of the list of the players on the team to the scoreboard.
/execute store score players playerCount run team list player

Finally, run the command on a repeating command block to test for only one player on a team.
/execute if score players playerCount matches 1 run [Your tp command here]

Also, keep in mind that if kept on the "player" team, the one player at the end will continuously teleport to that location.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome