bbekec avatar image
bbekec asked

How to set a string of all player's user data to 0 by cloud script?

Hello, I want to set all player's user data in a function.

I m holding a string dictionary like "<score, '345'>" for each player. I want to reset all player's scores to 0 by running a function in the cloud script. Is it possible? How can i do it?


10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Sarah Zhang avatar image
Sarah Zhang answered

Technically, it’s possible. The documentation Scheduled tasks quickstart can help you get started. If you want to manually reset all player's player data in batches, you can set the [Type of task] to [Run actions on each player in a segment] and set [SCHEDULE] to [Manual]. You also need to notice the player data updating limits which can be found in the title limits page([YourTitleId]/limits).

However, generally, for the application scenarios of “Score”, Leaderboards will be better than player data. Leaderboards are rankings of entities such as players, groups, or items that contain the built-in resetting feature, you can check Tournaments and leaderboards quickstart to get started with it and navigate to the documentation Using resettable statistics and leaderboards for more about resetting feature.

Please choose the feature more suits your situation and feel free to discuss with us if you need help with the corresponding CloudScript function.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bbekec avatar image bbekec commented ·

Hello, thanks for your answer. I am also using leaderboards but it resets everyday automatically as i choosed. I prefer to reset it because, there are inactive users. When i want show TOP 100 in the game, the score's of inactive users are also shown in it. For this reason, i need to hold scores in a different variable in cloud and i choosed the this way (PlayerData).

I made a mistake in the game before and many of player's scores are not their real score. For this reason i will make a score reset for all players just one time.

I havent used cloud scripting yet and i have no idea about it actually. If possible, can you share a code block for me as an example to do this?


0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang bbekec commented ·

Please check this documentation CloudScript quickStart to get started with CloudScript. For your case, the following code could be a reference.

handlers.completedLevel = function (args, context) {
    //You can modify it to “var newScore=args.Score;” to get the Score value from “args”
    var newScore = 0;
    var updateUserDataResult = server.UpdateUserData({
        PlayFabId: currentPlayerId,
        Data: {
            Score: newScore
    return { updateUserDataResult: updateUserDataResult };

0 Likes 0 ·
bbekec avatar image bbekec commented ·

Thank you so much Sarah. I will try it.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.