How do I make the player name show up on a /tellraw command? [duplicate]
You'll need to use selectors. These are things like @a
, @p
, etc. (Look at the link for adding things like scoreboard). To use this in /tellraw
, use the following:
"extra":[{"selector":"@p"}]
So, let's say we want a command to say "Hi! My name is ..." Try this:
/tellraw @a {"text":"Hi! My name is ","extra":[{"selector":"@p"}]}
To break it down,
/tellraw @a @a means all, so this goes to everyone in the world
{"text":"Hi! My name is ", The "text" part tells tellraw that the next part
(denoted by :) in quotes is text to be displayed.
"extra":[{"selector":"@p"}]} The "extra" tag says the next part is something
extra (figures). Then, the "selector" tag says the
next part is a selector, and "@p" means the nearest
player from where the command is being run.
Probably More than You Need to Known, Just Putting it Here Anyways
To tell everyone in the world, use @a
. To tell everyone with a score of 3 in the objective Kills
, use
@a[score_Kills=3,score_Kills_min=3]
In English, it means "Anybody (@a
) with a maximum score of 3
and a minimum score of 3
". This may sound weird, but since the only number with a maximum of 3 and a minimum of 3 is, well, 3, that command only targets players with 3 as their Kills
score.