Multiplayer displaying scores of all players. :(

Hello friends,

Can any one help me for displaying scores of all players in multiplayer. I am using get player array from game state but the array which I am getting is different in index orders in server and client so, while displaying on the screen the score order changes in client and server. Please suggest me some way for this.

Thanks in advance

Hi Ganesh,

I’m sorry the array is different across machines, this is something we’d like to make easier in a future version. For now, one solution is to track a unique player ID in your own replicated variable on the PlayerState. You can assign this number on the server in the PostLogin event (which only runs on the server), for example, and since clients will receive the replicated PlayerState, they can use this ID to track players uniquely - and even to sort the entries of a scoreboard.

Hi Ryan,
thanks for the answer I am using almost same way, In my game when all players gets connected and after that at the beginning of game play I fetch all the connected players array and saved it to my custom replicated array in Game state (This fetching and new custom array creation function is executed only on Server). And after that this replicated custom array I am using for displaying purpose. Is it proper way ?

Thanks

Hi Ganesh,

If that solution works for you, great! But if your game supports join-in-progress, you’ll probably need to update the array when players join as well.

Yes I did that when new player joins. :slight_smile: