Forum Discussion

dello32's avatar
dello32
Member
8 months ago
Solved

Simple leaderboard don't update value

Hello meta creators,
I need some help because I truly want to cry. Since I deleted the leaderboard in ONE world, it's now impossible for me to get the leaderboard working in any world.
 
Can someone test this script to update a leaderboard?
 
Create a leaderboard in /Systems/leadersboard with the name "test".
 
Create the leaderboard at /Entity Build/Gizmo/WorldLeaderboard, and set its Leaderboard to "test".
 
Create a script object: Scripts/[+]/ and paste the code.
 
Create a Trigger and set its script to execute this code.
 
import * as hz from 'horizon/core';
export class TriggerScoreUpdater extends hz.Component<typeof TriggerScoreUpdater> {
  start() {
    this.connectCodeBlockEvent(this.entity, hz.CodeBlockEvents.OnPlayerEnterTrigger,
      (enteredBy: hz.Player) => {
        console.log(`Player ${enteredBy.name.get()} set leaderboard to 42`);
        this.world.leaderboards.setScoreForPlayer("test", enteredBy, 42, false);
      }
    );
  }
}
hz.Component.register(TriggerScoreUpdater);
 
Does it work for you? What am I doing wrong? :'(
  • I think there is a setting in your horizon menu that lets you exclude yourself from leaderboards.

4 Replies

  • Everything appears correct, also worked for me. I invited you as a editor to the world.

     

    • dello32's avatar
      dello32
      Member

      Thanks for the test. In facr my profil seems broken, people can update the leaderboard, but not me. I'm in holidays but i will test your world when i can, i suppose that i won't appeare in your leaderboard.

      • SeeingBlue's avatar
        SeeingBlue
        Mentor

        I think there is a setting in your horizon menu that lets you exclude yourself from leaderboards.

    • InaCentaur's avatar
      InaCentaur
      Member

      can you also invite me - it'd be nice to learn from a working example of this!