mojira.dev
MCPE-168575

scoreboard.getScore() method does not update scoreboard display

When a scoreboard displayed on the sidebar is changed with the script API’s setScore(), the sidebar does not update. When using runCommandAsync, the scoreboard display updates properly. To replicate this

  1. Have the below script applied to a world

  2. Run "/scoreboard objectives add test dummy test"

  3. Run "/scoreboard objectives setdisplay sidebar test"

  4. Say "set 1 cmd" - player's score shows up as 1 because it was run through runCommandAsync()

  5. Say "set 2 script" - sidebar does not show player's score as 2 even though "/scoreboard players list @s" shows that the player's score is 2

import { world } from '@minecraft/server';

world.events.beforeChat.subscribe(e => {
    const player = e.sender;
    const message = e.message.split(' ');
    if (!(message[0] === 'set')) return;
    e.cancel = true;
    switch (message[2]) {
        case 'cmd':
            player.runCommandAsync(`scoreboard players set @s test ${message[1]}`);
            break;
        case 'script':
            world.scoreboard.getObjective('test').setScore(player.scoreboard, parseInt(message[1]));
            break;
    }
});

Here is a link to a video of my tests on google drive: https://drive.google.com/file/d/1aXpEKWhsgMk_6w5FyBUXjM-JktFCL_FP/view?usp=drivesdk

Comments 2

Resolving temporarily as Awaiting Response. Could you check if the script below works correctly for what you're trying to do?

import { world, system } from "@minecraft/server";world.beforeEvents.chatSend.subscribe((e) => {
  const player = e.sender;
  const message = e.message.split(" ");
  if (!(message[0] === "set")) return;
  e.cancel = true;  system.run(() => {
    switch (message[2]) {
      case "cmd":
        player.runCommandAsync(`scoreboard players set @s test ${message[1]}`);
        break;
      case "script":
        world.scoreboard.getObjective("test").setScore(player.scoreboardIdentity, parseInt(message[1]));
        break;
    }
  });
});

This ticket will reopen automatically when you reply.

Can confirm. The scoreboard now updates on the sidebar as expected.
Thank you

Gassayping33

(Unassigned)

Unconfirmed

iOS

iPadOS 16.3.1

Script-API

1.19.71

Retrieved