As players join and leave, I need something(s) giving a redstone signal for every number of players from 1-10, then if there is more than 10. So I can have one thing happen at 1 player, something different happen at 2, 3, 4 ...

I have tried using a comparator output from "/testfor @a", but I couldn't get it to do things like having the command blocks for players=1 and players=2 to turn off if players=3. Everything else I've tried had the same problems, and everything I've found online is for testing for a min/max amount of players.

  • Why is this getting downvotes? – SonicBlue22 Oct 7 '16 at 2:02
  • I searched for a while, and I tried "/testfor @a" with a comparator going out, then a line of redstone, but I couldn't get the command blocks before the one for the actual number of players to turn off. Everything else I tried had the same kind of problem. – SonicBlue22 Oct 7 '16 at 2:27
  • You should word that into your question. Include everything you've tried. – Timmy Jim Oct 7 '16 at 2:29
  • What version of Minecraft is this? – Matias K Oct 9 '16 at 17:05

I'd use a scoreboard to hold the value of the amount of players, you can count how many are on with:

/execute @a ~ ~ ~ /scoreboard players add <dummy player> <objective> 1

then you can use conditional command blocks after a command like this:

/scoreboard players test <dummy player> <objective> <min> <max>

note: min and max can be set the same for an exact number

but if you want a redstone value of player count, @mookooy gave the answer for that


Have a Repeating, Always Active command block with the command /testfor @a and a comparator and no repeater this will produce a signal strength based on the number of players online


Set up some command blocks like this:

[Repeating, always active] /scoreboard players set @e[name=Counter] players 0

[Chain, always active] /execute @a ~ ~ ~ /scoreboard players add @e[name=Counter] players 1

Create a scoreboard objective named players:

/scoreboard objectives add players dummy

Then place some entity in the world and name it "Counter". I'd recommend summoning an invisible armor stand:

/summon ArmorStand ~ ~ ~ {CustomName:Counter,Invisible:1,Marker:1,NoGravity:1}

Finally, it really depends on what you need to do. If you REALLY need a redstone output out of it, add these to commands blocks:

[Chain, always active] /setblock x y z air

[Chain, always active] /execute @e[name=Counter,score_players_min=10,score_players=10,c=1] ~ ~ ~ /setblock x y z redstone_block

Replace x y z with the X Y and Z coordinates of where you want the redstone block to be placed. Press Fn-F3 to open Debug Mode, and then you can see coordinates.

If there 10 players in the world, it will place a block.

Hope this helps!

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.