2

It seems like my command won't work, can anyone help me? I spent more than 30 minutes on this command and it still won't work. I put the command in the command block and it lights up, even if there is only 1 player

Here's the command; what am I doing wrong?

/testfor @e[team=Red,c=2]
1

1 Answer 1

2

c=2 in 1.12 and limit=2 in 1.13 is a restriction to at most that many entities. So if there are 3 players, it would just select 2. But if there is only 1, it would find that one player.

To put the number of players on a team into a scoreboard called "playerCount", execute this command:

/execute store result score dummyPlayer playerCount if entity @e[team=Red]

You don't even need a run and chained command, since execute if without a chained command just gives back the number of matched entities.

dummyPlayer is in this command, who would have thought, a dummy player. You can then run commands under the condition that it's higher than or equal to 2 like this:

/execute if score dummyPlayer test matches 2.. run <command>
2
  • For 1.13 replace /execute @a[...] ~ ~ ~ with /execute as @a[...], same with @e. Aug 17, 2017 at 6:37
  • I'll properly update this answer to 1.13 at a later point, because I need to check in Minecraft whether I do it right. And when I'm at my PC, I currently have better things to do. :D But just translating the commands here to their 1.13 equivalents works for now, it's just not performance optimised. Oct 22, 2018 at 8:19

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