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
Have the below script applied to a world
Run "/scoreboard objectives add test dummy test"
Run "/scoreboard objectives setdisplay sidebar test"
Say "set 1 cmd" - player's score shows up as 1 because it was run through runCommandAsync()
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
Resolving temporarily as Awaiting Response. Could you check if the script below works correctly for what you're trying to do?
This ticket will reopen automatically when you reply.