Minecraft – How to get command block talking in chat to nearby players

minecraft-commandsminecraft-java-edition

I'm trying to get a command block to write in the chat, and it is working, but it is displaying it to all players in the server. I only want the chat to appear to the player that steps on the pressure plate. Ive tried everything from @p and @s.

example of text I try is below

/tellraw @p {"text":"Hello World!"}

but that tells it to every player. I've tried

/tellraw @p[distance=3] {"text":"Hello World!"}

but that doesn't work either.

Best Answer

Well, “distance” isn’t a tag, use r instead.

Also, @p would only do one player, so use @a. This would make

/tellraw @a[r=3] {“text”:”Hello World!”}.