Leaderboard Issue - First Record added is incorrect

Greetings, I’m creating a leaderboard and adding a record. When adding a record, the first record I add is always wrong and it adds the next records. Every time I rerun Nakama, the first record I add to the leaderboard gets wrong and the next succeed. Drops into Catch on TryCatch.

Hi @emredarak.

Please can you explain what you mean when you say the record is wrong? Can you share some code and any errors you’re seeing too, as well as which version of Nakama you’re running.

I’m using version 3.14.0 of nakama.

try {
nk.leaderboardRecordWrite(“id”,userId, null,score)
} catch (error) {
logger.error(error)
}

I use this method to add record to Leaderboard. And when I add a user for the first time, it gives an error. When I try for the second time, a record is successfully created on the leaderboard.

Please share the error you are receiving when it fails.

I could see the error it gave when try catch cancelled.

rpc error: code = Internal desc = TypeError: expects number at github.com/heroiclabs/nakama/v3/server.(*runtimeJavascriptNakamaModule).leaderboardRecordWrite.func1 (native)

It sounds like you’re not passing a number through to the function correctly. Can you verify that your Score variable is correct?

The number I got was of float64 type. So we cannot add numbers with commas to the leaderboard. We can only add integers.

That’s correct, you’ll need to convert your score to a whole integer before submitting it to the leaderboard.

1 Like