How to teleport someone somewhere else when they stand at a specific location, with the command block somewhere out of sight

Solution 1:

  1. Give yourself a command block.
/give @s command_block
  1. To avoid having your chat being over run by messages, set the game rule CommandBlockOutput to false.
/gamerule commandBlockOutput false
  1. Go to the purple block and stand on top of it. Once you are standing on the block, press F3 (Fn + F3 on some keyboards) to find your coordinates. These will be referred to as x1, y1, and z1

(Optional) Type your coordinates into chat to help you remember them.

  1. Now, go to the red block, and repeat step 3. These will be referred to as x2, y2, and z2.

  2. Now, go to where you want the command block to be placed, and place it there.

  3. Right-click your mouse on it, and change Impulse to Repeat.

  4. Now change Needs Redstone to Always Active.

1.13+

Enter the text:

tp @a[x=X1, y=Y1, z=Z1, distance=..0.5] X2 Y2 Z2

into the area that says Console Command.

1.12.2-

Enter the text:

tp @a[x=X1,y=Y1,z=Z1,r=1] X2 Y2 Z2

into the area that says Console Command.

  1. Hit the button labeled Done.