Minecraft – way to put spaces in a scoreboard player name

minecraft-commandsminecraft-java-edition

Note that this is only focusing on Minecraft Java Edition, and for versions 1.13+. I am predominantly looking for a solution that does not require any external programs (like MCEdit or NBTExplorer) and will work in just plain vanilla Minecraft, although if the only solution doesn't fit these criteria, I'll still take it (since having a solution is better than no solution!)

Essentially, I am looking for a way to put a phrase (meaning essentially there are two or more words and spaces are involved) on a Minecraft scoreboard.

This is what I mean by 'phrase': One two three, 1 2 3

These are not 'phrases': OneTwoThree, One-Two-Three, One_Two_Three, 1-2-3, etc.

However, it seems like the only way to add text to an objective on the scoreboard is to add a "fake player", via /scoreboard players add [playername] [objectivename] [score], which shows the [playername] and the [score] part of the command on the scoreboard. However, since player names can't have spaces at all, it means that you can't have a phrase shown on the scoreboard.

I have seen on many servers scoreboards that do have phrases listed on the scoreboard, but I have no idea how they do this (probably because of plugins that can do this sort of thing).
An example of phrases/spaces being used on a scoreboard on a Minecraft server

I did notice that teams can be given display names that can have spaces, so is there a way to display the team name on the scoreboard (thus being able to put phrases on there?)?

Overall, my main question would be "Is there a way to use spaces on the scoreboard (excluding the objective name) in vanilla Minecraft?

Best Answer

Putting spaces in the scoreboard objective heading

The scoreboard objective ID cannot contain spaces, that is, the ID that you reference the objective with. However, the display name can contain spaces, simply by putting spaces in the JSON text component. Because this functionality wasn't present in the screenshot, you may have thought that it isn't possible. But it is.

/scoreboard objectives add luckyBlockBrawl dummy [{"text":"Lucky Block Brawl!!!"}]

Putting spaces in scoreboard player names

The fake player names themselves cannot contain spaces. If you try to put spaces in the command, it just moves onto the next argument. But there is a way...

The fake player names in the screenshot you provided are coloured. How did the mapmakers do that?
The answer lies in teams.

Teams have many different attributes, including the ability to set their colour. When a colour is set, the fake player name in the scoreboard changes to match that colour, as you can see in the screenshot above.

But there is another property that lets the name have spaces, and it involves clever use of team prefixes and suffixes. When a prefix/suffix is provided, it appears before/after the player's name (real or fake). Prefixes and suffixes are provided in JSON text format, just like the objective display name:

PREFIX: [{"text":"The Honourable Player"}]
NAME:   ExpertCoder14
SUFFIX: [{"text":"is awesome!"}]

will show as

The Honourable PlayerExpertCoder14is awesome!

As you can see, the prefix and suffix can contain spaces, and these will be rendered in the scoreboard player name. Notice that because I didn't provide spaces in the prefix and suffix, the ExpertCoder14 is not space-separated from the prefix/suffix.

So for the screenshot you've provided, the real player name is some part of the rendered text. It could be one letter of the name, it could be up to one word of the name. But the space and the rest of the name is actually part of the team prefix/suffix.

You can even put in multiple sections to have multicoloured scoreboard player names. Take a look at this question and answer.