Hello! I’m trying to figure out if this would throttle datastore with a maximum of eight players? onPlayerExit is just my save mechanic.
while true do
for i, v in pairs(game.Players:GetChildren()) do
onPlayerExit(v)
end
task.wait(45)
end
Hello! I’m trying to figure out if this would throttle datastore with a maximum of eight players? onPlayerExit is just my save mechanic.
while true do
for i, v in pairs(game.Players:GetChildren()) do
onPlayerExit(v)
end
task.wait(45)
end
Depends on how you save the data. If you save 1 value per player then its ok, if you save more than 2 there might be problems.
TIP: make an autosave function that saves every 60 seconds AND an onPlayerExit function. If the server crashes then the data will be saved some might be lost but you can only make a little progress in 60 seconds (unless the player gets an insanly rare item right before the server crashes, but what are the odds of that… data loss reports exist.), however, if its onPlayerExit only then the data will only save once the player leaves, if the server crashes the data wont be able to save… AND, if the player has been in the server nonstop grinding for 6 hours without leaving then thats A LOT of progress lost… it might even make some players quit forever
small edit: use tables for datastores, e.g: {Coins = 1562, Level = 3}, NOT a datastore for every value
Autosaving might cause issues if you are saving a-lot of players at the same time.
When a player closes roblox or crashes it still fires the PlayerRemoving event. The only time this might fail is when the server itself starts to lag hard or crashes. (Which shouldn’t happen in the first place.)
Autosaving every minute probably isn’t a good idea since you’re given a minute as buffer time. If you exhaust the minute with autosaves, it leaves little room for actual players joining or leaving. If you added the 45 second buffer into the for loop (therefore saving a player or two every minute), then maybe that would allow for more fluid autosaving.
OP specified 8 players maximum in each server, so it should be ok here
autosaving one player per 5 seconds is a good idea if you have a lot of players… it should be ok to save all the players if you have less than 10
also if the server shuts down for any reason it will have to save all the players at once (and its not a good idea if there is a lot of them)
also by crash I mean any of these:
core game script breaks because of an error that was never discovered (always use pcall for something that might error)
server crashes/shuts down
…im not listing all of them…