How can I testfor only one player in a specific place? [duplicate]
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] - 2 Men in Red and White Jersey Shirt Sitting on Grass Field](/assets/images/how_can_i_testfor_only_one_player_in_a_specific_place_duplicate_1.jpeg)
![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] - Redbull](/assets/images/how_can_i_testfor_only_one_player_in_a_specific_place_duplicate_2.jpeg)
![How can I testfor only one player in a specific place? [duplicate] - Free stock photo of active, activewear, activity How can I testfor only one player in a specific place? [duplicate] - Free stock photo of active, activewear, activity](/assets/images/how_can_i_testfor_only_one_player_in_a_specific_place_duplicate_3.jpeg)
How do you test a player in Minecraft in a certain area?
2. Type the CommandHow 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
