Forum Discussion

rico.stenson's avatar
rico.stenson
MHCP Member
4 months ago
Solved

Leaderboards.setScoreForPlayer error

Hello, 

I am just trying to call setScoreForPlayer, but getting and error sayinng that I am passing the server player when I'm pretty sure I'm not.  Eitherway, what is the proper way to call this?

I have the System->Leaderboards->WorldLeaderboard1 and a worldlbgizmo also called WorldLeaderboard1 that points to the systems leaderboard.   

//const lp = this.world.getLocalPlayer(); // tried this one first. error server player?

      const lp = this.entity.owner.get(); // same here error server player 

      if ( lp )  

      {

        this.world.leaderboards.setScoreForPlayer("WorldLeaderboard1",lp,score,false );

      }
Again getLocalPlayer and my local script this.entity.owner.get() also gets this same "server player" error.  

 

  • rico.stenson's avatar
    rico.stenson
    4 months ago

    Actually I figured out a way to do this.  I made a new script, set that to local, and then call the function in that script to call setScoreForPlayer.  That is working now.  So if you're running into this issue... just handle the lb update in a separate local script and that should be fine.  

2 Replies

  • Just to clarify, I am calling setScoreForPlayer from a script that is set to local, not default.  Also the function is just an update function in that same local script which I thought was running locally also.  But I guess it isn't????  So how do I properly get a real local player so I can call this leaderboard function properly? 

    • rico.stenson's avatar
      rico.stenson
      MHCP Member

      Actually I figured out a way to do this.  I made a new script, set that to local, and then call the function in that script to call setScoreForPlayer.  That is working now.  So if you're running into this issue... just handle the lb update in a separate local script and that should be fine.