# How do I testfor a certain amount of players in a certain radius?

So I am making a Spleef game on my server and I need to testfor 12 players within about 35 blocks from the command blocks.

I tried `/testfor @a[r=35]` leading into a `/tp` command to teleport the players into the Spleef arena. What I don't have is to make it only teleport 12 players and not any more or less. So if you can help me with this I'd appreciate it.

There is the count target selector argument.

``````/tp @p[x=<X>,y=<Y>,z=<Z>,r=<Radius>,c=<Count>] x y z
``````

To detect if there is 12 players or more, there are 2 main ways to do it. One is simply with a comparator leading from a `/testfor @a[x=<X>,y=<Y>,z=<Z>,r=<Radius>]`, which will emmit a redstone signal strength equal to the amount of players in that area and you can run a redstone wire to activate the teleport command, or do it with a scoreboard counter.

• Common mistake, the c=count doesn't say test for no more than count entities. It says match count entities (which is returned by the comparator in terms of redstone strength) If you put c=12 it will result true if only 1 entity matches, output signal strength 1. If you put c=12 and there are say 20, it will result true and output strength 12. So that doesn't work for the 'not any less'. The best way is to wire comparator and then 12 redstone dust then maybe repeater or just second commandblock. Commented Aug 3, 2015 at 14:44

Using /testfor in a command block while using r= for your radius. To test for a count with no more or no less you'll have to use dust equal to that ammount.

• `testfor @p[r=radius, c=maxCount]` Circular radius centered on the command block

• `testfor @a[r=radius, c=maxCount]` (Will match dead people supposedly)

• `testfor @a[x=px, y=py, z=pz, r=radius, c=maxCount]` Radius from px,py,pz

Needless to say, you will need a clock. (I know there are faster clocks) The first commandblock (lower left) is your testfor, and the upper command block would be your `tp @p[x=px, y=py, z=pz, r=radius, c=maxCount]`

The blocks in my left toolbar are the materials used for the commands setup, and on the right toolbar are for the clock.

You can easily use PLAYER ARGUMENTS. To do it in your case, you should put a command block with this command inside:

/testfor @a[r=35,c=12]

Then, you have to put a comparator next to the Command Block. Done!

• This will not work for what OP wants. `c` puts an upper cap on the number of players that can be found, not a lower cap. Thus, the comparator will activate even with just 1 player. Commented Apr 22, 2015 at 19:32
• Now that I reason on it, you are right. Commented Apr 23, 2015 at 12:05