Minecraft – /say command (how to name the command block)

minecraft-bedrock-editionminecraft-commands

I want to have a command block named the same as the nearest player. I t tried naming it @p, but when I ran the command, it stayed [@p] (message). What should I do?

Best Answer

If you want to make the command block say a command as if the closest player is saying it, you should use the /execute command.

It's really simple. What the command does is that it executes the command on behalf of an entity. The specific command you're looking for looks like this:

/execute @p ~ ~ ~ say <message>

If the nearest player's name is Dragonmaster, and the message you want to say is "Hello, world!", then the chat message will look like this:

[Dragonmaster] Hello, world!