I was looking for a simple teleportation system that let players teleport after they do a certain action. My idea was to make players teleport after they drop a certain item. Currently I've got: /execute if entity @e[type=item,name="Iron Ingot" run teleport @p 100 64 100. The problem with this however is that it teleports the player relatively closest to the command block, not the item obviously. How can I make the player closest to the item teleport to a certain coordinate?


1 Answer 1


execute at shifts the command execution.

/execute at @e[type=item,…] as @p at @s run tp …

Also, the syntax of the command in your question has some errors.

  • Wow, Thank you so much, it works! I have a little trouble reading the code however. Can you perhaps tell me what is going on, so I know what to do in the future? :)
    – NoTimeLeft
    Commented Jul 18, 2019 at 14:08
  • 1
    Firstly, a command is being run at the position of an item entity named "Iron Ingot". The next subcommand in the /execute modifies who is running the command: the closest player. Then, the next subcommand, at @s, changes the executing position to that of the executing entity, which is the closest player. Then, the tp statement is run as that player. Overall, the command finds an item on the ground, identifies the closest player and runs a teleport command as that player at that player's position.
    – Nik3141
    Commented Jul 18, 2019 at 15:17
  • @NoTimeLeft If you find this helpful, please upvote and accept it.
    – L. F.
    Commented Jul 19, 2019 at 4:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .