I am trying to make a datastore system for a game, but the Throttled Request warning keeps appearing, and I'm only sending one request. This is the script:

local datastore = game:GetService("DataStoreService")
local ds = datastore:GetDataStore("CashSaveSystem")

game.Players.PlayerAdded:connect(function(plr)
	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = plr
	leaderstats.Name = "leaderstats"
 	local cash = Instance.new("IntValue")
	cash.Parent = leaderstats
	cash.Name = "Cash"

	ds:SetAsync(plr.UserId, cash.Value)
	cash.Value = ds:GetAsync(plr.UserId) or 1000
 	ds:SetAsync(plr.UserId, cash.Value)
	wait(1)
 	cash.Changed:connect(function()
  		ds:SetAsync(plr.UserId, cash.Value)
 	end)

end)

6 comments

0

cash.Changed is most likely your problem. Change it to once every 5 or 10 mins and when the player leaves the game.

0

i use that all the time if the message is in orange it will just save a second after

0

I'd set up an autosave function every 5 minutes or so instead of every time your cash value changes. 90% sure that is your problem.

0

Clearly you all were not reading the question. I only sent one request, and it gave me the Request Throttled message.

0

for every request i made, it gave me that message.

0

and like it says in the question, the DataStore just isn't working. It isn't saving or loading anything.