I am working on a datastore, and I it only saves one value, I need help figuring out why, I am not posting all the code, but this is the main part of it, I am using a dictionary for saving the values
Code:
function module.load(plr, stats, name)
local dataService = game:GetService("DataStoreService"):GetDataStore(name)
local leaderstats = plr:WaitForChild("leaderstats")
local key = plr.UserId.. "-key"
local savedValues = dataService:GetAsync(key)
if savedValues then
for index, value in pairs(savedValues) do
leaderstats[tostring(index)].Value = value
end
else
for index,value in pairs(stats) do
local values = {}
values[tostring(index)] = leaderstats[tostring(index)].Value
dataService:SetAsync(key, values)
end
end
end
Here is the bit of code that I believe is messing up:
for index,value in pairs(stats) do
local values = {}
values[tostring(index)] = leaderstats[tostring(index)].Value
dataService:SetAsync(key, values)
end
Heres a warning that is appearing:
16:53:10.544 - Request was throttled. Try sending fewer requests. Key = 83240285-key

3 comments
Try putting line 18 along with the values variable declaration outside the for loop.
Thank you so much
Put it as a answer and I will accept if you would like