As you can see, the scoreboardâs position is above the players head.
What is the problem?
The board doesnât appear above the head of my player, it does appear above everyoneâs head, but player.getName() is the name of my player.
Example: When I see other players, above everyoneâs head is a scoreboard with my name.
This is not how it should work. Everyone should have his own name above his headâŚ
What do you mean? Could you post a screenshot with where youâre trying to display it?
Thatâs how it works. When you call player.setScoreboard(scoreboard), you set the scores that are displayed to that player. Let me know if you need clarification.
Players already have their own names displayed above their heads.
Example: Iâm with 3 Minecraft accounts online. Every player has a scoreboard (Content: player.getName();)
The problem: When I look at the other 2 players, above their head stands âHitzk0pfâ, but I want to see their name above their heads.
Do you understand me now?
I think youâve misunderstood how scoreboards work.
By itself, an Objective doesnât actually cause anything to be displayed. Instead, the Scores added to an Objective are displayed on the client, depending on which display slot is set for the Objective in question.
I do understand you. Let me explain the reason for this:
First, players that are viewing a scoreboard (the ones that you call setScoreboard on) see the Objective set to DisplaySlots.BELOW_NAME above every playerâs head.
Second, if you call setScoreboard on a player, nobody else sees any change. Only the player you call setScoreboard on knows anything about that particular scoreboard or the Objectives within it.
Yes, I know that, but I donât want that
Is there a way to set a scoreboard for a player? Like I said, I want to put (for example) the uuid of the player above his head (in the scoreboard).
The other option is to summon, and update an armor stand floating above the players with the name of what you want, with the marker interface like a hologram, but you would need to update the armor stands position constantly.
No they donât. Since itâs only the number that changes, it shows whatever score the player has for the given objective. but the display name of the objective is fixed and common for all the players visible to the viewer.
First, sorry if youâve misunderstood me. I donât think I was very clear about per-player scoreboards vs objective display slots
The simplest way to replicate the screenshot you posted is to have everyone using the same scoreboard. If you donât explicitly set it, everyone will be using the server scoreboard (which is persisted accross restarts, and accessible through the /scoreboard command.
What youâll probaby want to do is create a new scoreboard, then set it for all of your players. You can get a scoreboard by calling Scoreboard.builder().build, and calling setScoreboard on each Player with the instance you get back.
This first creates a Scoreboard, then adds an objective to it, setting it into the BELOW_NAME display slot. It then loops over the connected players twice: Once to add a score for each player (replace 123 with some actual score value), and once to set their scoreboard to the fully initialized scoreboard.
The reason for looping twice is so that when a player gets their scoreboard set, itâs already fully initialized, with everyoneâs score added.