What command can I use to detect when any player is in a certain area?

What command can I use to detect when any player is in a certain area? - Crop hacker silhouette typing on computer keyboard while hacking system

I have tried using commands from /testfor @a[r=4.5], /tp @a[r=4.5], /entitydata @e[type=Player,r=4.5], etc. and nothing works. I want it to teleport any player within range of my machine. It kind of works as a giant portal but it doesn't work without the teleporting part (duh).

Cons: I can't use @e because there's armor stands in the area for other reasons and eventually I'm going to start spawning zombie's in the area for (also) other reasons. I am using 1.10.2 so maybe that's the reason the commands aren't working. Please answer for me and those with similar problems.



Best Answer

You cannot use decimal points in selectors. Try something like:

/tp @a[r=4] X Y Z



Pictures about "What command can I use to detect when any player is in a certain area?"

What command can I use to detect when any player is in a certain area? - Focused ethnic female DJ playing music at nightclub
What command can I use to detect when any player is in a certain area? - From above of crop anonymous male hacker typing on netbook with data on screen while sitting at desk
What command can I use to detect when any player is in a certain area? - Crop unrecognizable man cleaning computer system unit



How do you detect if a player is in a certain area?

detectPos is the x y z coordinate to detect the block. command is any Minecraft command that you want the entity to execute such as summon, give, fill, clone, setblock, tp, xp, kill, etc.

How do I trigger command blocks when a player walks in a certain area?

There is someone you want to get to but you don`t know where they are so you type /locate playername!



How to detect if a player is at a certain place! Java 1.16.1 COMMANDS IN DESCRIPTION




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

Images: Anete Lusina, Fardad Postwala, Sora Shimazaki, Anete Lusina