Why am I getting an 'unexpected token' error with this Minecraft /give command?
I'm trying to make a sign that you can right click and it will clear cacti from your inventory, then give you 18 cookies named "$100 Cookie" with the lore "$100". But when I put it in a command block and power it, the command block says this:
[04:23:51] Data tag parsing failed: Unexpected token
$
at:$100 Cookie\\",Lore:[$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"
The command I'm using is:
give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p[name=rainbowlack,r=3] cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p[name=rainbowlack,r=3] minecraft:cookie 18 0 {display:{Name:\"$100 Cookie\",Lore:[$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}
What's wrong with this command? I've tried backslashes and stuff. Can you please try to fix the command and test out your potential fix in-game? Thank you!
You'll have to change the [name=rainbowlack,r=3]
parts to whatever your username is (example: [name=playerplayer123,r=3]
).
Related: Why are my quotation marks causing an “unexpected token” error with this command?
Best Answer
Place backslashes in front of the $
symbols. If the rest of the command is correct, this should work:
/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p[name=rainbowlack,r=3] cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p[name=rainbowlack,r=3] minecraft:cookie 18 0 {display:{Name:\"\$100 Cookie\",Lore:[\$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}
Also, including the username shouldn't be necessary as far as I can tell. Why not:
/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true,\"clickEvent\":{\"action\":\"run_command\",\"value\":\"clear @p cactus 0 2304\"}}",Text2:"{\"text\":\"2304 Cacti\",\"color\":\"red\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"give @p minecraft:cookie 18 0 {display:{Name:\"\$100 Cookie\",Lore:[\$100]}}\"}}",Text3:"{\"text\":\"iIiIiIi\",\"color\":\"light_purple\",\"strikethrough\":true,\"obfuscated\":true}",Text4:"{\"text\":\"[Sell]\",\"color\":\"dark_purple\",\"bold\":true}"},display:{Name:"Custom Sign"}}
Pictures about "Why am I getting an 'unexpected token' error with this Minecraft /give command?"
How do you fix syntax error near unexpected token then?
One Approach to Fix Them AllWhy do I keep getting a syntax error in minecraft?
You forgot to give the player argument leading to a syntax error. This is the programming term for a grammar error. The unexpected " is related to the internal representation of the item name you supplied.What is the meaning of syntax error near unexpected token?
This error message also surfaces when you are entering commands in the Linux command line for everyday tasks such as copying files manually etc. The main reasons why this error message occurs is either because of bad syntax or problem of the OS in interpreting another system's commands/shell.What are the minecraft commands?
List and summary of commandsCommandDescriptionBE/difficultySets the difficulty level.Yes/effectAdds or removes status effects.Yes/enchantAdds an enchantment to a player's selected item.Yes/eventUsed to trigger an event on an entity.Yes25 more rowsBuzzcocks - What Do I Get? (Official Video)
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: RODNAE Productions, RODNAE Productions, RODNAE Productions, RODNAE Productions