0

I am trying to run a title command when a player right clicks a sign. Here is my command for spawning the sign (generated here):

/give @p sign 1 0 {
    BlockEntityTag: {
        Text1: "{\"text\":\"---------------\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"tp @s 0 66 13\"}}",
        Text2: "{\"text\":\"Right click once\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"playsound entity.player.levelup master @s ~ ~ ~ 10 1\"}}",
        Text3: "{\"text\":\"accepted!\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/title @s title {\\"text\\":\\"Welcome to the Server!\\", \\"bold\\":true, \\"italic\\":false, \\"color\\":\\"green\\"}\"}}",
        Text4: "{\"text\":\"---------------\"}"
    },
    display: {
        Name: "Custom Sign"
    }
}

However I get an error here:

{\\"t <---

I assume because of the double escape characters or nested quotes, but I tried single quotes and tried single escape characters to no avail. How would I run this command?

7

1 Answer 1

1

You were very close. You saw that the title command required double escapement of the special characters. In your case, you tried \\". A quote which is single escaped is \". To double escape it, you have to escape both characters which gives \\\"

Here is a working command with the changes:

/give @p sign 1 0 {BlockEntityTag:{Text1:"{\"text\":\"---------------\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"tp @s 0 66 13\"}}",Text2:"{\"text\":\"Right click once\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"playsound entity.player.levelup master @s ~ ~ ~ 10 1\"}}",Text3:"{\"text\":\"accepted!\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/title @s title {\\\"text\\\":\\\"Welcome to the Server!\\\", \\\"bold\\\":true, \\\"italic\\\":false, \\\"color\\\":\\\"green\\\"}\"}}",Text4:"{\"text\":\"---------------\"}"},display:{Name:"Custom Sign"}}
0

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