Teleport a player away from certain entities?

Got multiple armor stands with the name _safezone_
, what I want to achieve is to basically have "safe domes" where no players can get in, except for the ones already inside.
So I tried setting up a command which teleports everyone near the armor stand named _safezone_
to spawn.
/execute @e[name=_safezone_] ~ ~ ~ /tp @a[r=128,rm=150] @e[c=1,name=_spawn_]
And it returns with an error that it coudn't execute the command as the entity _safezone_
. Is there a workaround - without spawning commandblocks everywhere? (or am I missing something?)
Best Answer
Use barrier blocks, theyre invisible, and cannot be broken. Not a fix, but a solution
Pictures about "Teleport a player away from certain entities?"



How do you teleport certain entities?
Players who want to move mobs to their character's position or move their character to the mob's position can use the following commands:How do you teleport a certain entity in Minecraft?
You can use the /teleport command to teleport a player or entity to a set of coordinates in the game (see also /tp command).How do you randomly teleport a player?
Try the /spreadplayers command, which spreads entities in a random area. The syntax is /spreadplayers <x> <z> <spreadDistance> <maxRange> <respectTeams> <player \u2026> In your case, you might want to try something like /spreadplayers ~ ~ 0 10000 false @a[r=5,c=1] .How do you teleport players in different dimensions?
To teleport yourself to another dimension, open the chat box and type: /execute in DimensionName run tp PlayerName ~ ~ ~.Minecraft Command Blocks: Randomized Teleportation of Entities around an Entity or Location
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Andrea Piacquadio, SHVETS production, Victoria Borodinova, Victoria Borodinova