I have a datastore script, when I run it, after placing a few items an error says 11:19:44.369 - Request was throttled. Try sending fewer requests.
here is my datastore script:
local tbl = {} or nil
repeat wait() until game:GetDescendants()
wait(.5)
local DataStore = game:GetService("DataStoreService"):GetDataStore("Vector_Saver")
local lastPos = Vector3.new(0,0,0)
-- getting player
for _, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Player") then
local name = v.Player.Value
print(name.." has joined the game :D")
Plr = game.Players:FindFirstChild(name)
end
end
repeat wait() until Plr
if DataStore:GetAsync(Plr.UserId) == nil then
table.insert(tbl,"000")
DataStore:SetAsync(Plr.UserId,tbl)
else
end
DataStore:GetAsync(Plr.UserId)
-- setting data / saving it
for _, v in pairs(DataStore:GetAsync(Plr.UserId)) do
print(v)
end
workspace["Player Scripts..."].Event.Changed:Connect(function()
if Plr then
for _, v in pairs(Plr.HiddenStats.ItemPos:GetChildren()) do
lastPos = v.Value
table.insert(tbl, tostring(v.Value))
end
DataStore:SetAsync(Plr.userId, tbl)
else
wait()
end
end)
I save it on line 31 How to get it to stop saying that error?

2 comments
userId is deprecated, switch to UserId. On each SetAsync there should be at least a 6 second cooldown.
Okay thanks!