# Issue with using 'incr' incremental leaderboards in a lua module

**URL:** <https://forum.heroiclabs.com/t/issue-with-using-incr-incremental-leaderboards-in-a-lua-module/292>\
**Category:** Local Setup\
**Created:** [October 22, 2019, 10:56am UTC](https://forum.heroiclabs.com/t/issue-with-using-incr-incremental-leaderboards-in-a-lua-module/292 "2019-10-22T10:56:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![asheraryam](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@asheraryam](https://forum.heroiclabs.com/u/asheraryam)\
**Post date:** [October 22, 2019, 10:56am UTC](https://forum.heroiclabs.com/t/issue-with-using-incr-incremental-leaderboards-in-a-lua-module/292/1 "2019-10-22T10:56:56Z")

</div>

I have an issue with using ‘incr’ leaderboards in a lua module. (Nakama 2.6.0)

I was using the leaderboard with the `best` parameter, and the leaderboard settings didn’t update the setting when I changed the leaderboard initialization code.

I update the leaderboard but only the best value is recorded for the user. It seems it’s still acting as if it’s a `best` leaderboard.

Do I have to manually delete the leaderboard from the server to make it update the settings?

I was able to fix it by changing the leaderboard name I’m using from “totalCoins” and “totalRewards”, but it would be great if the leaderboard settings could be changed when needed (even if means deleting all the leaderboard data).

More details:

Not only for the match or even for the session, the value is just **never incremented** unless there is a new “best” value given that’s higher than the recorded one.

The leaderboard set call does not return an error and the log file shows no errors.

Here is the whole method I’m using  
here: [https://pastebin.com/LSRHEunc](https://pastebin.com/LSRHEunc)

For clarification, when I added a logger call under `if changeset.coins >0` then it was printing that it’s updating the leaderboard when it should  
i.e. when `skip_leaderboard` is false and when `coins` are positive.

But when i check the leaderboard afterwards it always only shows the first/best value set.  
The leaderboard is defined with  
`nk.leaderboard_create(plat .. "-" .. "totalCoins", authoritative, sort, "incr", reset, metadata)`

Should I open a github issue?

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [October 22, 2019, 12:59pm UTC](https://forum.heroiclabs.com/t/issue-with-using-incr-incremental-leaderboards-in-a-lua-module/292/2 "2019-10-22T12:59:10Z")

</div>

This is not a bug, leaderboard settings cannot be updated after the leaderboard is created. Too much logic and behaviour depends on the settings to be changed on the fly.

Leaderboard creation is short-circuited if the leaderboard ID you’re trying to create already exists to allow repeat creation of a known set of leaderboards in server startup phases.

If you want to change the operator of a leaderboard you should delete and create it again, but this should not be a common operation in production - I expect this is something you’ll only want to do for development?

---

<div class="post-metadata">

**Author:** ![asheraryam](https://avatars.discourse-cdn.com/v4/letter/a/a698b9/32.png) [@asheraryam](https://forum.heroiclabs.com/u/asheraryam)\
**Post date:** [October 22, 2019, 1:03pm UTC](https://forum.heroiclabs.com/t/issue-with-using-incr-incremental-leaderboards-in-a-lua-module/292/3 "2019-10-22T13:03:12Z")

</div>

You’re right I can’t imagine needing to do that very often, I just didn’t see an error when trying to overwrite the leaderboard and imagined there was something wrong with it.

We could possibly have this in the leaderboard docs somewhere to mitigate this.

---

<div class="post-metadata">

**Author:** ![zyro](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/zyro/32/14_2.png) [@zyro](https://forum.heroiclabs.com/u/zyro)\
**Post date:** [October 22, 2019, 1:04pm UTC](https://forum.heroiclabs.com/t/issue-with-using-incr-incremental-leaderboards-in-a-lua-module/292/4 "2019-10-22T13:04:33Z")

</div>

We do [mention this](https://heroiclabs.com/docs/gameplay-leaderboards/#leaderboard-object) but it’s not specifically highlighted.

> All leaderboard configuration is immutable once created. You should delete the leaderboard and create a new one if you need to change the sort order or operator.
