Leaderboard Issue - undefined error


#1

Dear friends - I am trying to create a leaderboard at http://leaderboards.metaverseapp.io/
however, I keep getting error - ‘undefined’. How to resolve this? does anyone know?


#2

Hey @khs1dub,

When you create a leaderboard, make sure that the name/description of your leaderboard does not contain any special characters ()$#@!{}±&^

Hope this helps! :slight_smile:


#3

Hi Luis!

Thank you so much for the help :slight_smile:

This solved it. I have another topic. I have added the Leaderboard - in my game I ask students to enter their student registration number at the beginning which is saved as a text using ${props.UserName_ID}. Is it possible that Leaderboard can show results as per this student number instead?

I think the following code needs to be modified:

const user = await Meta.contexts.loadUser(Meta.data.event.subject);
Meta.actions.post(‘http://leaderboards.metaverseapp.io/api/update.php’, {
method: ‘post’,
headers: {
Accept: ‘application/x-www-form-urlencoded’,
‘Content-Type’: ‘application/x-www-form-urlencoded’,
},
body: apikey=${leaderboard}&username=${user.name}&increment=${increment},

But how?


#4

Glad that worked!

So in this case, you can use your saved text (user property) by swapping out user.name with Meta.$user.PROPERTY_NAME

The line in the code that should be customized will look like this:
body: apikey=${leaderboard}&username=${Meta.$user.PROPERTY_NAME}&increment=${increment}

Here is an experience that you can clone to take a look:

Hope this helps! :slight_smile: