Minecraft – Selector command in tellraw command does not work

minecraft-commandsminecraft-java-edition

Is this a 1.9 thing, or is my selector in my /tellraw command not working?
Here is the code:

/tellraw @p ["",{"text":"[",{selector:"@p"},"]"},{"text":" Woah, this is wierd.","color":"gold"}]

For me, in 1.9 (16w02a), the command is not working. Nothing will appear in chat.

However, when I take out the selector:

/tellraw @p ["",{"text":"[ ]"},{"text":" Woah, this is wierd.","color":"gold"}]

It works fine.
Is the way I did the selector for @p wrong?

Best Answer

Your syntax is incorrect; you had not closed the current object before opening a new one within the array (causing a syntax error due to an object being opened without a name).

"text":"[", { selector

As of 1.9, JSON input must be strict, in that quotes must surround key names and string values. Your selector tag was missing quotation marks around the key.

Fixed command:

/tellraw @p ["",{"text":"["},{"selector":"@p"},"]",{"text":" Woah, this is wierd.","color":"gold"}]
Related Topic