I really new to Playfab and followed the code I found but I dont know why the value is always 0. The score is updated but the value is still 0. The score is added in another script, is it OK?
Also, I received the error messages:
Failed to update leaderboard: HTTP/1.1 409 Conflict UnityEngine.Debug:LogError (object)
Failed to update leaderboard: The client has exceeded the maximum API request rate and is being throttled
public IEnumerator SendLeaderboardCoroutine(int score)
{
var request = new UpdatePlayerStatisticsRequest
{
Statistics = new List<StatisticUpdate>
{
new StatisticUpdate
{
StatisticName = "Platform Score",
Value = score
}
}
};
PlayFabClientAPI.UpdatePlayerStatistics(request, result =>
{
if (result != null)
{
Debug.Log("Leaderboard updated successfully!");
}
else
{
Debug.LogError("Failed to update leaderboard: result is null.");
}
}, error =>
{
Debug.LogError("Failed to update leaderboard: " + error.ErrorMessage);
});
// Wait for a short delay after the PlayFab API call
yield return new WaitForSeconds(1f);
}