Contains objectives and participants for the scoreboard.

Properties

displayName: string

Returns the player-visible name of this scoreboard objective.

This property can throw when used.

id: string

Identifier of the scoreboard objective.

This property can throw when used.

Methods

  • Parameters

    • participant: string | Entity | ScoreboardIdentity

      Participant to apply the scoreboard value addition to.

    • scoreToAdd: number

    Returns number

    Adds a score to the given participant and objective.

    This function can't be called in read-only mode.

    This function can throw errors.

    import { world } from "@minecraft/server";

    const money = world.scoreboard.getObjective("money");
    const player = world.getPlayers()[0];
    const currentScore = money.addScore(player, 100);
    player.sendMessage(`Your current score is ${currentScore}`);
    import { world } from "@minecraft/server";

    const money = world.scoreboard.getObjective("money");
    const player = world.getPlayers()[0];
    const currentScore = money.addScore(player, -100);
    player.sendMessage(`Your current score is ${currentScore}`);
  • Parameters

    Returns number

    Returns a specific score for a participant.

    This function can throw errors.

  • Returns ScoreboardScoreInfo[]

    Returns specific scores for this objective for all participants.

    This function can throw errors.

    import { world } from "@minecraft/server";

    const money = world.scoreboard.getObjective("money");
    var scoreArray = money.getScores();
    scoreArray.sort(function (a, b) {
    return b.score - a.score;
    });

    console.log(scoreArray.map((score) => score.participant.displayName));
  • Parameters

    Returns boolean

    Returns if the specified identity is a participant of the scoreboard objective.

    This function can throw errors.

  • Returns boolean

    Returns true if the ScoreboardObjective reference is still valid.

  • Parameters

    Returns boolean

    Removes a participant from this scoreboard objective.

    This function can't be called in read-only mode.

    This function can throw errors.

  • Parameters

    Returns void

    Sets a score for a participant.

    This function can't be called in read-only mode.

    This function can throw errors.

    import { world } from "@minecraft/server";

    const money = world.scoreboard.getObjective("money");
    const player = world.getPlayers()[0];
    money.setScore(player, 0);
    player.sendMessage(`Your score has been reset.`);