I want to be able to detect if a certain word in chat is said like:

Console: Please say yes to be teleported or no to remain
Player1: yes
Player1 teleported to [insert random coordinates here]

Something that would monitor the chat for a certain word.


Unfortunately there is simply no way, currently, to test for what players say in chat.

There is however an alternative which is quite similar; using /tellraw along with the new (1.8 snapshots only so far) /trigger command. This would allow you to create a message in chat that looks something like this:

Would you like to be teleported? [Yes]

And would actually work when you clicked the [Yes] button.

First you'll need to create an objective (lets say, Objective1) with type "trigger". Then, you'll need to use /scoreboard players enable Player1 Objective1 to allow Player1 to use /trigger Objective1. You'll need to do this each time you ask the player if they want to teleport.

Then, to display the actual clickable message, run something like this in a command block:

/tellraw Player1 {"text":"Do you wish to be teleported? ","extra":[{"text":"[Yes]","clickEvent":{"action":"run_command","value":"/trigger Objective1 set 1"}}]}

This sets their Objective1 score to 1, and from there you can simply do something like /tp @a[score_Objective1_min=1] Coordinates.

Here's a site that's quite useful for generating tellraw commands; there is a lot you can do with them but the syntax can initially be very confusing: http://ezekielelin.com/minecraft/tellraw/


Even simpler than the above, again made with the very useful tool ezekielelin's tellraw generator If you put this into a command block all you need to do is change the [target player] and x, y, z and add/ remove the x and y rotation

tellraw @a {"text":"","extra":[{"text":"Do you want to be teleported?"},{"text":"[Yes]","clickEvent":{"action":"run_command","value":"/tp [target player] <x> <y> <z> [<y-rot> <x-rot>]"}}]}
  • I can't verify this right now, but I am 95% sure that this won't work without the player that clicks having access to /tp himself (i.e. op). This is the entire reason Trigger objectives and the /trigger command were implemented in the first place. – MrLemon Jul 30 '14 at 11:07
  • MrLemon is correct. This will only work for someone with operator permissions, which is why I used the longer trigger method in my answer. – SirBenet Aug 10 '14 at 19:57
  • FYI, you don't need to use the "extra":[] element anymore. Instead of {"text":"one","extra":[{"text":"two"}]}, try [{"text":"one"},{"text":"two"}] – ExpertCoder14 Aug 11 '20 at 1:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.