today i was making a scoreboard sidebar for my java server and i wanted to make a name with spaces, i don't know how to do that so i added "_". But it looks horrible, so how can i add spaces to my texts?
-
7We've already answered this question here: Is there a way to put spaces in a scoreboard player name?– ExpertCoder14Apr 26, 2021 at 15:04
2 Answers
You could join the 'fake' players in a team that has a custom prefix/suffix so that you don't need to use an underscore/hyphen. Here's an example:
# Add a team, modify its prefix option, then join the `SMP` fake player in it
team add 15SMP
team modify 15SMP prefix {"text": "15 "}
scoreboard players set SMP <objective> 2
team join 15SMP SMP
This should now display the SMP
'fake' player as 15 SMP
in the <objective>
scoreboard objective
-
This is actually a great workaround that I had no idea it existed! I'd just point out I immediately went to try it and turns out the JSON object isn't needed (nor allowed) - you can set the prefix as simply as
/team modify 15SMP prefix "15 "
. Apr 26, 2021 at 13:04 -
Notice the synopsis of the scoreboard add
command:
scoreboard objectives add <objective> <criterion> [<displayName>]
It has an optional <displayName>
argument, that can be used to set custom, user-friendly names. While <objective>
argument must be a unique, one-word identifier, you can set the <displayName>
to anything you want.
In order to use spaces in the <displayName>
argument, surround it in quotation marks:
/scoreboard objectives add objective1 dummy "Name with spaces"
You can then check it with:
/scoreboard objectives setdisplay sidebar objective1
/scoreboard players set @s objective1 1
EDIT: I noticed you are using the identifiers with spaces in the scoreboard players
command as well. Setting display names or using spaces in these identifiers isn't allowed in Java Edition, unfortunately. It is possible only in the Bedrock Edition, as BE uses generic strings as identifiers, whereas JE does not. However, eggohito brought up a neat trick that can circumvent that in their answer!