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
participant: Entity | ScoreboardIdentity | string
Identifier of the participant to retrieve a score for.
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
- participant: Entity | ScoreboardIdentity | string
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
participant: Entity | ScoreboardIdentity | string
Participant to remove from being tracked with this objective.
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
participant: Entity | ScoreboardIdentity | string
Identity of the participant.
score: number
New value of the score.
Important
This function can't be called in read-only mode.
Warning
This function can throw errors.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for