I get an error message when I want to get the value of the statistic "Playeravatar". In this case, the player doesn't have a value in the leaderboard "Playeravatar".
var avatarnumber = 0; var result = server.GetPlayerStatistics({PlayFabId: currentPlayerId, StatisticNames: "Playeravatar"}); if (result.error != null) { } else { if ((result.Statistics[0].Value != null) && (result.Statistics[0].Value != "")) { avatarnumber = result.Statistics[0].Value; } } return { avatarnumber };
"Error": { "Error": "JavascriptException", "Message": "JavascriptException", "StackTrace": "TypeError: Cannot read property 'Value' of undefined\n at handlers.GetPlayerAvatar (E5E2C-main.js:4168:35)\n at Object.invokeFunction (Script:116:33)" }
How can I find out in CloudScript if the player already has a value for the statistic "Playeravatar"?