So my datastore is throttling, and it's causing some people to lose their data because of it. I only save when a player buys currency or leaves the game.
Here I'm saving their stats when they buy points. Maybe when someone is repeatedly buying points? How should I fix this?
PointsEvent.OnServerEvent:Connect(function(player,asset)
for i,v in pairs(PointsModule.PointsInfo)do
if v.Name == asset then
MS:PromptProductPurchase(player,v.Id)
MS.ProcessReceipt = function(receiptInfo)
if player.UserId == receiptInfo.PlayerId then
if receiptInfo.ProductId == v.Id then
player:WaitForChild("leaderstats").Points.Value = player:WaitForChild("leaderstats").Points.Value + v.Amount
wait()
print("Saved player data!")
DataStore:SetAsync(player.UserId,player.leaderstats.Points.Value)
end
end
end
end
end
end)
Here I'm getting the data when they join the game. I don't really know why that would cause data loss. I'm including it just in case it does...
game.Players.PlayerAdded:connect(function(Player)
local ls = Instance.new("IntValue", Player)
ls.Name = "leaderstats"
local r = Instance.new("StringValue", ls)
r.Name = "Rank"
r.Value = Player:GetRoleInGroup(3281134)
local p = Instance.new("IntValue", ls)
p.Name = "Points"
p.Value = 0
local data = DataStore:GetAsync(Player.userId)
if data then
p.Value = data
end
end)
Here's where I save the data when they leave the game.
game.Players.PlayerRemoving:Connect(function(Player)
DataStore:SetAsync(Player.UserId,Player.leaderstats.Points.Value)
print("Saved "..Player.Name.."'s".." data!")
end)
How would I stop it from throttling? It's causing people to lose their data and it's especially bad when they buy items and it doesn't save...

5 comments
On your PlayerAdded, it should be Connect, not connect.
Has nothing to do with my problem though lol
I know, but it's always good practice to deviate from deprecated code.
Anyways you probably are sending too many requests, as the output says.
... I know this. I'm asking how do I stop it? I need to obviously get the data when someone joins and save when someone buys an item and when they leave the game.......