# Leaderboard but for clans?

**URL:** https://forum.heroiclabs.com/t/leaderboard-but-for-clans/5867
**Category:** Runtime Framework
**Created:** [December 13, 2024, 4:34pm UTC](https://forum.heroiclabs.com/t/leaderboard-but-for-clans/5867 "2024-12-13T16:34:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![virtouso](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/virtouso/32/679_2.png) [@virtouso](https://forum.heroiclabs.com/u/virtouso)
#### Post date: [December 13, 2024, 4:34pm UTC](https://forum.heroiclabs.com/t/leaderboard-but-for-clans/5867/1 "2024-12-13T16:34:03Z")

</div>

i need leaderboard for clans in nakama? is there any best practices?

i know there are many ways to do it but just simply instead of saveLeaderboardScore with userId saving it with clan id can make the leaderbord but i think its not possible.  
in general a group score is sum of its users scores.  
is there any best practice for it?

---

<div class="post-metadata">

### Author: ![od-jg](https://avatars.discourse-cdn.com/v4/letter/o/94ad74/32.png) [@od-jg](https://forum.heroiclabs.com/u/od-jg)
#### Post date: [December 16, 2024, 4:27am UTC](https://forum.heroiclabs.com/t/leaderboard-but-for-clans/5867/2 "2024-12-16T04:27:26Z")

</div>

If you use the [authoritative leaderboard API](https://heroiclabs.com/docs/nakama/server-framework/typescript-runtime/function-reference/#leaderboardRecordWrite) then I think you can make the score’s owner ID anything you want. The [docs](https://heroiclabs.com/docs/nakama/concepts/leaderboards/#leaderboard-records) also specifically mention this:

> All records belong to an owner. This is usually a user but other objects like a group ID or some other custom ID can be used

I imagine it’s more efficient for each group member to score to a single group ID than to query every member of every group and tabulate the sum of their scores, but I can’t say for certain. I also don’t know how concurrent writes are handled if many players in a group score at the same time, but that’s the sort of thing I think Nakama handles well.

---

<div class="post-metadata">

### Author: ![sesposito](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/sesposito/32/2594_2.png) [@sesposito](https://forum.heroiclabs.com/u/sesposito)
#### Post date: [December 16, 2024, 3:42pm UTC](https://forum.heroiclabs.com/t/leaderboard-but-for-clans/5867/3 "2024-12-16T15:42:55Z")

</div>

Hello @virtouso,

@od-jg is correct, if there’s no need to keep the individual scores around, then the best way to handle it is to set up a leaderboard with `incr` operator, any submitted score with the guild ID will be added to the existing score. The increment is handled in the db so concurrent updates are safe.

Best.
