Update offline player's stats

How would I go on about updating a player’s stats even if that player is not online? (Yes, my leaderstats save).

This is what I’m trying to achieve. For example, if the admin inputs a valid userID in the textbox and then clicks on promote, the player whose ID was inputted would get their “RankIndex.Value” increased by one.

I’ve tried searching for a solution, and I’ve tried to use UpdateAsync/SetAsync. It does update something (used print for debug), but when that player logs on, they have their previous value instead of the new one.

2 Likes

If you are using the player ID as the datastore key (which you should be doing), then you can just getasync on the userid, rewrite whatever data is necessary, and call updateasync

3 Likes

DataStore:SetAsync(Key, Value)

1 Like

UpdateAsync provides its transform function(s) with the current state of the data, so there’s no need for GetAsync

I still haven’t come to a solution. Maybe I’m doing something wrong, but I honestly don’t know what. It’s late rn, so maybe I’ll try to fix in the morning, but I doubt it. I don’t know why it’s not working. Whenever I use updateasync to overwrite data, the player whose data was updated always loads their previous data, completely ignoring the update (if it even worked properly).

  1. Do you have DataStore for leaderstats?

  2. Does your system uses RemoteEvent?

alright after playing around some more, I managed to fix it on my own. After I put the data in a table it began to work, so it’s all good now. Thank you for trying to help!

1 Like