#[RESOLVED] Dummy/Fake Player Scoreboard

1 messages · Page 1 of 1 (latest)

frail bone
#

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);
thorn fractal
#

Hey! On my phone and at work, so here’s a reference I can pass that might help. Consider looking at Entity class to get scoreboard info for a player rather than world class

frail bone
frail bone
#

I have just seen this again, the reason this did not work was due to have the scoreboard name and fake player name the wrong way round

frail bone
#

[RESOLVED] Dummy/Fake Player Scoreboard