#How to ensure all players have a ScoreboardIdentity at all times

1 messages · Page 1 of 1 (latest)

green shadow
#

I've tried adding the players to a scoreboard whenever they join the world but it doesn't seem to work unless I rejoin the world

Current Code:

world.events.playerSpawn.subscribe(e => {
  if (e.initialSpawn) return
  
  e.player.runCommandAsync('scoreboard players add @s identity 1')

  console.warn(`${e.player.scoreboard.id}`) // Throws an error as Player.scoreboard is undefined.
})```
obtuse smelt
#
world.events.playerSpawn.subscribe(async e => {
  if (e.initialSpawn) return
  
  await e.player.runCommandAsync('scoreboard players add @s identity 1')

  console.warn(`${e.player.scoreboard.id}`) // Throws an error as Player.scoreboard is undefined.
})
green shadow
#

that

#

makes a lot of sense

#

thank you very much

mellow tree
#

in general its not a good idea to be using runCommandAsync

#

go for native functions, they are much faster

#

whenever possible

obtuse smelt
#

Setting score for first time cannot possible with native method for now, so command is only way