How To Get Command Blocks Talking in Chat

I need a way for a command block to say things in chat when it is powered, or more preferably whenever someone spawns into the world.


Solution 1:

There are two ways you can output things to the chat.

The /say command, syntax /say <Message ...> displays a message in chat. However, this message will always have the command block's name beside it.

A command block with /say Hello World! would output:

[@] Hello World!

Alternatively, the /tellraw command, syntax /tellraw <target> <json compound array/singleton> displays a message in chat, but it gives you full customization of its output from color to formatting using json formatting.

A command block with /tellraw @a {"text":"Hello World!"} would output:

Hello World!

There are applications such as minecraftjson.com which generates a json string to use in /tellraw and various other commands that will give you complete control on what is outputted.

There is also a Minepedia section on the string format should you decide to write them yourself.

Solution 2:

Use the /say command. This allows a command block to display a chat message to the entire server.

More info on the /say command on the Minecraft wiki

Solution 3:

First of all, to detect a Player do:

/testfor @e[type=Player]

In a repeating command block (always active). Then, have a chain command block (always active), connected to the first, saying:

/say <YOUR MESSAGE>