Skip to content

@minecraft/server


@minecraft/server / ScoreboardObjective

Class: ScoreboardObjective ​

Defined in: @minecraft/server/index.d.ts:19156

Contains objectives and participants for the scoreboard.

Properties ​

displayName ​

readonly displayName: string

Defined in: @minecraft/server/index.d.ts:19165

Remarks ​

Returns the player-visible name of this scoreboard objective.

Throws ​

This property can throw when used.


id ​

readonly id: string

Defined in: @minecraft/server/index.d.ts:19172

Remarks ​

Identifier of the scoreboard objective.

Throws ​

This property can throw when used.


isValid ​

readonly isValid: boolean

Defined in: @minecraft/server/index.d.ts:19179

Remarks ​

Returns true if the ScoreboardObjective reference is still valid.

Methods ​

addScore() ​

addScore(participant, scoreToAdd): number

Defined in: @minecraft/server/index.d.ts:19190

Parameters ​

participant ​

string | Entity | ScoreboardIdentity

Participant to apply the scoreboard value addition to.

scoreToAdd ​

number

Returns ​

number

Remarks ​

Adds a score to the given participant and objective.

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.


getParticipants() ​

getParticipants(): ScoreboardIdentity[]

Defined in: @minecraft/server/index.d.ts:19197

Returns ​

ScoreboardIdentity[]

Remarks ​

Returns all objective participant identities.

Throws ​

This function can throw errors.


getScore() ​

getScore(participant): number | undefined

Defined in: @minecraft/server/index.d.ts:19206

Parameters ​

participant ​

string | Entity | ScoreboardIdentity

Identifier of the participant to retrieve a score for.

Returns ​

number | undefined

Remarks ​

Returns a specific score for a participant.

Throws ​

This function can throw errors.


getScores() ​

getScores(): ScoreboardScoreInfo[]

Defined in: @minecraft/server/index.d.ts:19214

Returns ​

ScoreboardScoreInfo[]

Remarks ​

Returns specific scores for this objective for all participants.

Throws ​

This function can throw errors.


hasParticipant() ​

hasParticipant(participant): boolean

Defined in: @minecraft/server/index.d.ts:19222

Parameters ​

participant ​

string | Entity | ScoreboardIdentity

Returns ​

boolean

Remarks ​

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

Throws ​

This function can throw errors.


removeParticipant() ​

removeParticipant(participant): boolean

Defined in: @minecraft/server/index.d.ts:19234

Parameters ​

participant ​

string | Entity | ScoreboardIdentity

Participant 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 restricted-execution mode.

Throws ​

This function can throw errors.


setScore() ​

setScore(participant, score): void

Defined in: @minecraft/server/index.d.ts:19247

Parameters ​

participant ​

string | Entity | ScoreboardIdentity

Identity of the participant.

score ​

number

New value of the score.

Returns ​

void

Remarks ​

Sets a score for a participant.

This function can't be called in restricted-execution mode.

Throws ​

This function can throw errors.