Contains objectives and participants for the scoreboard.

Hierarchy

  • Scoreboard

Constructors

Methods

  • Parameters

    • objectiveId: string
    • Optional displayName: string
      Optional

    Returns ScoreboardObjective

    Remarks

    Adds a new objective to the scoreboard.

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

    Throws

    This function can throw errors.

    Example

    addObjective.js

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

    world.scoreboard.addObjective("example", "example");

  • Parameters

    • objectiveId: string

      Identifier of the objective.

    Returns ScoreboardObjective

    Remarks

    Returns a specific objective (by id).

    Example

    getPlayerMoneyObjective.js

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

    const money = world.scoreboard.getObjective("money");

  • Parameters

    Returns boolean

    Remarks

    Removes an objective from the scoreboard.

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

    Throws

    This function can throw errors.

    Example

    removeMoney.js

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

    world.scoreboard.removeObjective("money");

  • Parameters

    Returns ScoreboardObjective

    Returns the previous ScoreboardObjective set at the display slot, if no objective was previously set it returns undefined.

    Remarks

    Sets an objective into a display slot with specified additional display settings.

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

    Throws

    This function can throw errors.