Multiple Players Save

Hello, I just wanted to know how or if its even possible to save data of multiple players at once with one :SetAsync
I just want to know because if i would save data of completely server than theres 20 data requests and it wouldnt save all so yea.

Technically? yes. Practically? no. Would you ever do it? also no.

You can only save to one key per request, putting multiple players data in one key does not make sense.

You can use a for loop to save everyone’s data.

That’s not what OP is asking

Saving player data should be per player, you should retrieve it when they join and save it when they leave each to a unique key which has their userid in it

that wasnt my question…
then the datastore would have to many requests and only 5 or idk save

:SetAsync() is a yielding function, you cannot write to multiple keys at once under the same thread at the exact same time. It is also impractical to write a new thread on a per-user basis just to write data. You should have no problems pushing individual SetAsync requests one at a time. Always write them under a pcall.

(and if the data is being accessed across multiple servers, opt for UpdateAsync instead).

the thing is i want to prevent duping in my game
i need it for an jackpot system i want to save the datas if jackpot ended beacuse people could use a dupe glitch and get there items back if they lose :frowning:

why don’t you look at this

Post explaining session locking

ProfileService I highly recommend you use

To prevent duping you need to read if that data key gets loaded in multiple servers at the same time. You can write systems to do this. However, I would just recommend using ProfileService, which has built in calls against duping.

Our games write a few data keys. All primary data is handled through ProfileService, while global leaderboard data and read-only gets pushed to a separate key.

session locking dont really prevent duping…
session locking saves like the time and checks if you was in another server earlier but the thing is as duper you can just wait the time with an dupe method that means its useless :confused:

Yeah I don’t why you are telling me that as if you know, I thought you were asking.

Session locking “locks the data” to that session and the only way to get it in another session is to wait for the data to be unlocked, this prevents very bad race conditions bugs such as duplication.

also please speak in clear sentences, I don’t know what “you can just wait the time with an dupe method that means its useless” means

You can save upto 40 players in a server, as in my game it works, and I do it when game is shutting down for update the script loops and saves all the players data