Question about scoreboards


I have this code:

public void playerCustomScoreboard(Player player) {

	Jugadores jugador = new Jugadores(plugin_m, this, player.getUniqueId());
	Scoreboard prueba = player.getScoreboard();
	 Objective obj = Objective.builder()
                .displayName(Text.of(TextColors.RED, player.getName()))
	 obj.getOrCreateScore(Text.of(TextColors.GOLD, "Balance: $", jugador.getPlayerBalance())).setScore(2);
	 obj.getOrCreateScore(Text.of(TextColors.GOLD, "Oficio: ", jugador.getJobName())).setScore(4);
	 //Reset del scoreboard actual
	 for (Objective objective : player.getScoreboard().getObjectives()) {
	 prueba.updateDisplaySlot(obj, DisplaySlots.SIDEBAR);

It triggers when a player logs into the server, but the problem is that everyone sees the scoreboard of the last player joined, anyone can tell me why?


I think you have to create a new scoreboard (Scoreboard.builder()) instead of using the player’s current one (player.getScoreboard()) because by default it’s the scoreboard shared for every player on the server.