PrivateconstructorReadonlydisplayThis property can't be read in early-execution mode.
ReadonlyidThis property can't be read in early-execution mode.
ReadonlyisThis property can't be read in early-execution mode.
Participant to apply the scoreboard value addition to.
This function can't be called in restricted-execution mode.
This function can't be called in early-execution mode.
This function can't be called in early-execution mode.
Identifier of the participant to retrieve a score for.
This function can't be called in early-execution mode.
This function can't be called in early-execution mode.
import { Player, system, world } from "@minecraft/server";
// Run `/scriptevent example:topplayer` in chat to display the top money scores.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:topplayer" || !(sourceEntity instanceof Player)) return;
const money = world.scoreboard.getObjective("money");
if (!money) {
sourceEntity.sendMessage("Scoreboard objective 'money' does not exist.");
return;
}
const scoreArray = money.getScores();
scoreArray.sort((a, b) => b.score - a.score);
const topNames = scoreArray.map((entry) => `${entry.participant.displayName}: ${entry.score}`);
sourceEntity.sendMessage(`Leaderboard: ${topNames.join(", ")}`);
});
This function can't be called in early-execution mode.
Participant to remove from being tracked with this objective.
This function can't be called in restricted-execution mode.
This function can't be called in early-execution mode.
Identity of the participant.
New value of the score.
This function can't be called in restricted-execution mode.
This function can't be called in early-execution mode.
Contains objectives and participants for the scoreboard.
Source