Skip to main content

Class: ScoreboardObjective

Contains objectives and participants for the scoreboard.

Constructors

new ScoreboardObjective()

private new ScoreboardObjective(): ScoreboardObjective

Returns

ScoreboardObjective

Properties

displayName

readonly displayName: string

Remarks

Returns the player-visible name of this scoreboard objective.

Throws

This property can throw when used.


id

readonly id: string

Remarks

Identifier of the scoreboard objective.

Throws

This property can throw when used.

Methods

addScore()

addScore(participant, scoreToAdd): number

Parameters

ParameterTypeDescription
participantstring | Entity | ScoreboardIdentityParticipant to apply the scoreboard value addition to.
scoreToAddnumber-

Returns

number

Remarks

Adds a score to the given participant and objective.

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

Throws

This function can throw errors.


getParticipants()

getParticipants(): ScoreboardIdentity[]

Returns

ScoreboardIdentity[]

Remarks

Returns all objective participant identities.

Throws

This function can throw errors.


getScore()

getScore(participant): number

Parameters

ParameterTypeDescription
participantstring | Entity | ScoreboardIdentityIdentifier of the participant to retrieve a score for.

Returns

number

Remarks

Returns a specific score for a participant.

Throws

This function can throw errors.


getScores()

getScores(): ScoreboardScoreInfo[]

Returns

ScoreboardScoreInfo[]

Remarks

Returns specific scores for this objective for all participants.

Throws

This function can throw errors.


hasParticipant()

hasParticipant(participant): boolean

Parameters

ParameterType
participantstring | Entity | ScoreboardIdentity

Returns

boolean

Remarks

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

Throws

This function can throw errors.


isValid()

isValid(): boolean

Returns

boolean

Remarks

Returns true if the ScoreboardObjective reference is still valid.


removeParticipant()

removeParticipant(participant): boolean

Parameters

ParameterTypeDescription
participantstring | Entity | ScoreboardIdentityParticipant to remove from being tracked with this
objective.

Returns

boolean

Remarks

Removes a participant from this scoreboard objective.

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

Throws

This function can throw errors.


setScore()

setScore(participant, score): void

Parameters

ParameterTypeDescription
participantstring | Entity | ScoreboardIdentityIdentity of the participant.
scorenumberNew value of the score.

Returns

void

Remarks

Sets a score for a participant.

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

Throws

This function can throw errors.