Private
constructorReadonly
displayReturns the player-visible name of this scoreboard objective.
This property can throw when used.
Readonly
idIdentifier of the scoreboard objective.
This property can throw when used.
Participant to apply the scoreboard value addition to.
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}`);
Returns all objective participant identities.
This function can throw errors.
Identifier of the participant to retrieve a score for.
Returns a specific score for a participant.
This function can throw errors.
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));
Returns if the specified identity is a participant of the scoreboard objective.
This function can throw errors.
Participant to remove from being tracked with this objective.
Removes a participant from this scoreboard objective.
This function can't be called in read-only mode.
This function can throw errors.
Identity of the participant.
New value of the score.
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.`);
Contains objectives and participants for the scoreboard.