xMagmaDev
(Terrainny)
December 29, 2020, 3:54pm
1
Occasionally when I test-play my game in Studio, my data is reset back to 0… I also get this warning:
DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 375457526
I have exactly no clue on what this means and I am curious if this is the culprit to my data loss. Any ideas/clues?
Enxqi
(Enxquity)
December 29, 2020, 3:58pm
2
How are you saving or loading your data? Seems like your passing the request limit.
xMagmaDev
(Terrainny)
December 29, 2020, 4:00pm
3
I am using a DataStore… could you by any chance give me more of an explanation?
Enxqi
(Enxquity)
December 29, 2020, 4:01pm
4
Yeah I guess I wasn’t too specific. Do you have like a loop running which saves data every set amount of seconds?
xMagmaDev
(Terrainny)
December 29, 2020, 4:02pm
5
No, I have a table that holds all of the datastore values I want to save
Enxqi
(Enxquity)
December 29, 2020, 4:03pm
6
Would you mind sending some of the script because I can’t really review it otherwise?
xMagmaDev
(Terrainny)
December 29, 2020, 4:03pm
7
Sure:
local DS = game:GetService("DataStoreService"):GetDataStore("WWEDataStoreGet")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local savevalue = plr.leaderstats.Coins
local savevalue2 = plr.leaderstats.Bucks
local savevalue3 = plr.Equipped
local savevalue4 = plr.CoinsBoost
local savevalue5 = plr.BucksBoost
local savevalue6 = plr.leaderstats.Talent
local savevalue7 = plr.JoinedGroup
local savevalue8 = plr.FaveSuperstar1
local savevalue9 = plr.League
local GetSaved = DS:GetAsync(plrkey)
if GetSaved then
savevalue.Value = GetSaved[1]
savevalue2.Value = GetSaved[2]
savevalue3.Value = GetSaved[3]
savevalue4.Value = GetSaved[4]
savevalue5.Value = GetSaved[5]
savevalue6.Value = GetSaved[6]
savevalue7.Value = GetSaved[7]
savevalue8.Value = GetSaved[8]
savevalue9.Value = GetSaved[9]
else
local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value, savevalue4.Value, savevalue5.Value, savevalue6.Value, savevalue7.Value, savevalue8.Value, savevalue9.Value}
DS:GetAsync(plrkey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Coins.Value, plr.leaderstats.Bucks.Value, plr.Equipped.Value, plr.CoinsBoost.Value, plr.BucksBoost.Value, plr.leaderstats.Talent.Value, plr.JoinedGroup.Value, plr.FaveSuperstar1.Value, plr.League.Value})
end)
Enxqi
(Enxquity)
December 29, 2020, 4:05pm
8
Could you try a print to see if it’s getting the data or not getting it at all.
Also, i’d do plr.UserId instead of plr.userId but I doubt thats the issue
xMagmaDev
(Terrainny)
December 29, 2020, 4:07pm
9
Where should I put the print in the script?
Enxqi
(Enxquity)
December 29, 2020, 4:09pm
10
so after the local GetSaved, on the next line you would want to do
for i,v in pairs(GetSaved) do
print(i,v)
end
And if you see a list of saved data then it means your saving works else it’s not finding any data.
xMagmaDev
(Terrainny)
December 29, 2020, 4:13pm
11
Here is what I got:
08:11:54.500 1 711 - Server - DataStore:18
08:11:54.501 2 46 - Server - DataStore:18
08:11:54.501 3 - Server - DataStore:18
08:11:54.501 4 0 - Server - DataStore:18
08:11:54.501 5 0 - Server - DataStore:18
08:11:54.502 6 0 - Server - DataStore:18
08:11:54.502 7 true - Server - DataStore:18
08:11:54.502 8 - Server - DataStore:18
08:11:54.503 9 1 - Server - DataStore:18
is this it?
Enxqi
(Enxquity)
December 29, 2020, 4:13pm
12
Yeah seems like you do have data, this may possibly be something with the loading.
I believe that the GetSaved returns nil so then it does the else statement and sends a GetAsync request again. Now you have sent 2 GetAsync requests in a split second, which is causing that error.
xMagmaDev
(Terrainny)
December 29, 2020, 4:15pm
14
It says something about holding too many data store requests… could this mean I have too much of it?
Enxqi
(Enxquity)
December 29, 2020, 4:17pm
15
What i’d recommend you to do is replace your loading with this-
local data;
local success,fail = pcall(function()
data = DS:GetAsync(plrkey) or {} --This table should contain the beggining stats if player has no data
end)
if success then
savevalue.Value = data[1]
savevalue2.Value = data[2]
savevalue3.Value = data[3]
savevalue4.Value = data[4]
savevalue5.Value = data[5]
savevalue6.Value = data[6]
savevalue7.Value = data[7]
savevalue8.Value = data[8]
savevalue9.Value = data[9]
else
print("Failed to load data",fail)
end
xMagmaDev
(Terrainny)
December 29, 2020, 4:23pm
16
I am still getting the error when I changed it…
Enxqi
(Enxquity)
December 29, 2020, 4:23pm
17
Can you show me your new script
xMagmaDev
(Terrainny)
December 29, 2020, 4:24pm
18
Will do:
local DS = game:GetService("DataStoreService"):GetDataStore("WWEDataStoreGet")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrkey = "id_"..plr.userId
local savevalue = plr.leaderstats.Coins
local savevalue2 = plr.leaderstats.Bucks
local savevalue3 = plr.Equipped
local savevalue4 = plr.CoinsBoost
local savevalue5 = plr.BucksBoost
local savevalue6 = plr.leaderstats.Talent
local savevalue7 = plr.JoinedGroup
local savevalue8 = plr.FaveSuperstar1
local savevalue9 = plr.League
local data;
local success, fail = pcall(function()
data = DS:GetAsync(plrkey) or {}
end)
if success then
savevalue.Value = data[1]
savevalue2.Value = data[2]
savevalue3.Value = data[3]
savevalue4.Value = data[4]
savevalue5.Value = data[5]
savevalue6.Value = data[6]
savevalue7.Value = data[7]
savevalue8.Value = data[8]
savevalue9.Value = data[9]
else
local NumbersForSaving = {savevalue.Value, savevalue2.Value, savevalue3.Value, savevalue4.Value, savevalue5.Value, savevalue6.Value, savevalue7.Value, savevalue8.Value, savevalue9.Value}
DS:GetAsync(plrkey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
DS:SetAsync("id_"..plr.userId, {plr.leaderstats.Coins.Value, plr.leaderstats.Bucks.Value, plr.Equipped.Value, plr.CoinsBoost.Value, plr.BucksBoost.Value, plr.leaderstats.Talent.Value, plr.JoinedGroup.Value, plr.FaveSuperstar1.Value, plr.League.Value})
print("Saved data")
end)
Enxqi
(Enxquity)
December 29, 2020, 4:25pm
19
After the else, you need to get rid of it because that’s calling another GetAsync() too fast. The time allowed between 2 requests is 5 seconds therefore it’s throttling your request.
Also that’s if it errors therefore I would print out the error if it gets there.
xMagmaDev
(Terrainny)
December 29, 2020, 4:27pm
20
Do I need to get rid of the local part or the GetAsync part?