How can I testfor only one player in a specific place? [duplicate]

How can I testfor only one player in a specific place? [duplicate] - Man Standing on Stair Case Looking Up

I am making a map and I need to testfor the last player alive in the arena. I tried with selectors, but I am not really into this. Can someone help me out?



Best Answer

Create a scoreboard

/scoreboard objectives add testScoreBoard dummy

Chech for amount of players in radius r

/stats entity @e[type=Player,r=10] set SuccessCount testScoreBoard @p

You can then say something if there are 2 player in range

/execute @p[score_scoreBoardTest_min=2] ~ ~ ~ say 2 players are in range

Reset the scoreboard every tick

/scoreboard players reset testScoreBoard @p

Put all those commands into repeating command blocks.

I'm using @p because i need a placeholder wich i can select with selectors. You can use a ArmorStand tho:

/stats entity @e[type=Player,r=10] set SuccessCount testScoreBoard @e[type=ArmorStand,tag=counter]

/execute @e[tag=counter,score_scoreBoardTest_min=2] ~ ~ ~ say 2 players are in range

/scoreboard players reset testScoreBoard @e[tag=counter]

Hope it helped :)




Pictures about "How can I testfor only one player in a specific place? [duplicate]"

How can I testfor only one player in a specific place? [duplicate] - 2 Men in Red and White Jersey Shirt Sitting on Grass Field
How can I testfor only one player in a specific place? [duplicate] - Redbull
How can I testfor only one player in a specific place? [duplicate] - Free stock photo of active, activewear, activity



How do you test a player in Minecraft in a certain area?

2. Type the Command
  • Test if Players are within 10 blocks. In this example, we will test to see if there are any players within a 10 block radius with the following command: /testfor @a[r=10] ...
  • Test if Mooshrooms are within 50 blocks. ...
  • Test if Nearest Player is at Level 20 experience.




  • How to detect a player using command blocks! | /execute command tutorial for 1.16 Minecraft Java




    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Kaique Rocha, Yogendra Singh, hxx.4m x s4i.z, Artem Podrez