Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Constant Datastore throtting how to stop?

game.Players.PlayerRemoving:connect(function(player)
	valuezsz = game.ServerStorage.Players[player.Name]
	for i,v in pairs(valuezsz:GetChildren()) do
		storau:SetAsync(player.UserId, v.Value)
	end
end)

every time someone leaves ingame the serverlog tells me datastore throttling

1 answer

This is not the correct way to save data. You are using the same key and saving each value to this key. This would only save the last value.

It is best to save a table in a key as one key can hold a large amount of data. This also saves on the number of requests needed to save and load player data.

Example:-

game.Players.PlayerRemoving:connect(function(plr)
	local saveData = {}
	for _, itm in pairs(game.ServerStorage.Players[player.Name]:GetChildren()) do
		saveData[#saveData +1] = itm.Value -- note this will save it as an array
	end
	-- save the data
	storau:SetAsync(tostring(player.UserId), saveData )
end)

i would also reccomend that you look at the following links:-

saving and loading data with datastores

Data store

I hope this helps

This discussion is preserved as it was. New answers, comments, and votes are closed.