ScoreboardObjective Class

Contains objectives and participants for the scoreboard.

Properties

displayName

read-only displayName: string;

Returns the player-visible name of this scoreboard objective.

Type: string

Warning

This property can throw errors when used.

id

read-only id: string;

Identifier of the scoreboard objective.

Type: string

Warning

This property can throw errors when used.

Methods

addScore

addScore(participant: Entity | ScoreboardIdentity | string, scoreToAdd: number): number

Adds a score to the given participant and objective.

Parameters

  • participant: Entity | ScoreboardIdentity | string

    Participant to apply the scoreboard value addition to.

  • scoreToAdd: number

Returns number

Important

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

Warning

This function can throw errors.

getParticipants

getParticipants(): ScoreboardIdentity[]

Returns all objective participant identities.

Returns ScoreboardIdentity[]

Warning

This function can throw errors.

getScore

getScore(participant: Entity | ScoreboardIdentity | string): number | undefined

Returns a specific score for a participant.

Parameters

Returns number | undefined

Warning

This function can throw errors.

getScores

getScores(): ScoreboardScoreInfo[]

Returns specific scores for this objective for all participants.

Returns ScoreboardScoreInfo[]

Warning

This function can throw errors.

hasParticipant

hasParticipant(participant: Entity | ScoreboardIdentity | string): boolean

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

Parameters

Returns boolean

Warning

This function can throw errors.

isValid

isValid(): boolean

Returns true if the ScoreboardObjective reference is still valid.

Returns boolean

removeParticipant

removeParticipant(participant: Entity | ScoreboardIdentity | string): boolean

Removes a participant from this scoreboard objective.

Parameters

Returns boolean

Important

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

Warning

This function can throw errors.

setScore

setScore(participant: Entity | ScoreboardIdentity | string, score: number): void

Sets a score for a participant.

Parameters

Important

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

Warning

This function can throw errors.