Minecraft – Display text and score above players character (mc 1.16.3)

minecraft-commandsminecraft-java-edition

I have tried to display a score value and a text above the player character/ under the name but all my attempts have failed (ish).

The score value i want to display is the player Xp level. I did it by running this command:

/execute as @a[limit=1,sort=random] store result score @s level run data get entity @s XpLevel 1

The text i want to show is the players rank. The higher level the player has the better rank for exemple if the player is in level 6 > 9 the player has iron rank… I did this by running example this command:

/execute as @a[level=6..9] run tag @s add iron_rank

Now i just want to display the level and rank above the players character/ under the name.
My Idea was to display the level score was to simply display the score belowname with this command:

/scoreboard objectives setdisplay belowName level

But when i switched to third person i couldn´t see the score under my name/over the character for some reason.

My idea to display the rank was to summon and then teleport an small and invisible armor stand with a custom name at the player. This works but the armor stand can be in the way for the player if you want to interact with something above you!

  1. /summon armor_stand ~ ~ ~ {Invisible:1b,Invulnerable:1b,PersistenceRequired:1b,NoBasePlate:1b,NoGravity:1b,Small:1b,CustomName:"{\"text\":\"Rank: iron\",\"color\":\"gray\"}",Tags:[iron_rank]},CustomNameVisible:1b
    
  2. /execute as @a[limit=1,sort=random,tag=iron_rank] at @s run tp @e[type=minecraft:armor_stand,tag=iron_rank] ~ ~1.5 ~
    

I also tried this with the level score but it has the same problems and it will require 1 command block per level! (The rank also require 1 command block per rank but it will be like 10 ranks but infinit levels)

I want it to look something like this.
enter image description here

Best Answer

You could either use teams or the marker tag for the armor stand. The marker tag removes the hitbox. For the teams you can have prefixes and suffixes. You can do it with mcstacker at https://mcstacker.net/ you have to create the team first then you can edit the team prefixes and suffixes. As well I suggest making a team if you use the armor stands marker tag to prevent collision. For teams you would I think have to use execute if commands to assign teams for each level and rank. below is the command for summoning the armor stand

/summon armor_stand ~ ~ ~ {Marker:1b}

as well you can add tags for other things. I suggest using mcstacker for command generation.

summary:

1: team prefixes and suffixes using the /team command

2: the marker nbt tag for armor stands

3: use mcstacker https://mcstacker.net/

your welcome.