Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[SOLVED] Question is solved?

Asked by 3 years ago
Edited 3 years ago

When I was making a script for the DataStore system for my game, every value there is a Changed function that makes lots of requests to save the progress when the value changes. Every time I do lots of changes I figured out it was the reason the DataStore is saying that there are too many requests and I confiscated the Changed function, what I did to prevent that is the value will only save when the player leaves (PlayerRemoving function). I'm not sure if it will affect the data of the player such as previous data progress will be wiped out accidentally. Did I do anything wrong?

i.e.

money.Changed:Function()
    --This is the Function I removed, I found out that the 6-second cooldown is already fine but I am having two decisions whether to keep it or remove it
    moneysystem:SetAsync(player.UserId, money.Value)
end)

The other function

game.Players.PlayerRemoving:Connect(function(player) 
    --The function I kept, it now makes less requests
    moneysystem:SetAsync(player.UserId, player.leaderstats.money.Value)
end)
0
This is definitely better, trying to save everytime the players money changes is not a good idea, and yeah, roblox will think you are spamming requests. What I would suggest is using spawn(function() with a wait loop to save the players data every few minutes or so. matiss112233 258 — 3y
0
If your game is going to use datastore alot, i would suggest to check DataStore2 script. vovik 9 — 3y
0
Okay, my game is going to use DataStore a lot too, thanks for the comments! cherrythetree 130 — 3y

Answer this question