I'm trying to merge a nametag system with a rank system, however my issue is I have no good way to retrieve players and their scoreboards. This is what I have currently:
system.runInterval(async => {
// const players = world.getPlayers
const white = world.getPlayers(({scoreOptions: [{minScore:0, maxScore:0, objective:"Team"}]}));
const red = world.getPlayers(({scoreOptions: [{minScore:1, maxScore:1, objective:"Team"}]}));
const blue = world.getPlayers(({scoreOptions: [{minScore:2, maxScore:2, objective:"Team"}]}));
// const objective2 = world.scoreboard.getObjective("Rank")
// const score2 = objective2.getScore(players);
// if (score2 == 0) {
// player.setDynamicProperty('playerRank', '')
// }
// const playerRank = player.getDynamicProperty('playerRank')
for (const player of white) {
player.nameTag = player.name;
}
for (const player of red) {
player.nameTag = '§c' + player.name + '§7';
}
for (const player of blue) {
player.nameTag = '§b' + player.name + '§7';
}
0}
)
The commented code should work if I was able to retrieve the players in a better way. I'm really new to scripting so I'm not sure how to get this to work properly.
I was thinking of getting all players to execute a scriptevent, however I'd think there is a better way to do that. So I'm coming here first.