Create Minecraft Execute Command?

pa
2

I'm currently building an adventure map and wanted to try the Execute command.

I've heard that you can do something with it when someone is in a certain place.

I wanted that when you go to a certain coordinate with a radius of 5 blocks that a say command is triggered.

Can someone send me the command and explain what it all means?

Sc

I would create an invisible armor stand at the coordinates with the tag "Position":

/ summon armor_stand ~ ~ ~ {NoGravity: 1b, Invulnerable: 1b, Invisible: 1b, PersistenceRequired: 1b, Tags: ["Position"]}

(~ ~ ~ = Coordinates)

Now you can see with the command whether a player is nearby:

/ execute as @e [tag = position] at @s if entity @p [distance = .5] run say I'm in a radius of 5 blocks

There's definitely a more elegant solution, but it should work too

Sc

(if you want the text to be output only once, then just enter / execute as @e [tag = position] at @s if entity @p [distance = .5] in a repeat command block and put a redstone operator in front of it is then activated when a player is nearby. Then simply set a normal command block to the comparator which outputs the command)