Hi scripters!
I am currently trying to track the score of a dummy player, but I am unsure how to check if the dummy has a score and if not, set it to 0
I currently have this:
const test =
world.scoreboard.getObjective("sb_test") ??
world.scoreboard.addObjective(
"sb_test",
"sb_test"
);
which of course gets the scoreboard, or if undefined, sets the scoreboard.
I then have this:
const testScore = test.getScore("sb_test") ?? test.setScore("FakePlayer","sb_test", 1);
Which I thought would set the score to 1 if undefined, but it isn't working that way.
I am then getting this error:
[Scripting][error]-Error: Failed to resolve identity for 'FakePlayer' at <anonymous> (Test.js:54)
I feel like I am being a dork and have missed something simple, so any help would be greatly appreciated 😉
EDIT: I was being a dork, I had the scoreboard name and player name the wrong way round:
const testScore = test.getScore("sb_test") ?? test.setScore("sb_test","FakePlayer", 1);