I’m trying to load in data saved using DataStore2 but every time i get into the game the data is not loaded.
The error im receiving is: “23:00:50.225 - DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Data Store = Weapons/41956221”
This is the portion of my code that loads in the data:
--==
local coins = datastore2("Coins", plr)
local EXP = datastore2("Experience", plr)
local Levels = datastore2("Levels", plr)
local Points = datastore2("Points", plr)
local Defense = datastore2("Defense", plr)
local Speed = datastore2("Speed", plr)
local Multiplier = datastore2("Multiplier", plr)
local Rebirths = datastore2("Rebirths", plr)
local Gems = datastore2("Gems", plr)
local MapsOwned = datastore2("Maps", plr)
local WeaponsOwned = datastore2("Weapons", plr)
local PetsOwned = datastore2("Pets", plr)
local valfolder = valuefolder
valfolder.Coins.Value = coins:Get(0)
valfolder.Experience.Value = EXP:Get(1)
valfolder.Levels.Value = Levels:Get(1)
valfolder.Points.Value = Points:Get(0)
valfolder.Defense.Value = Defense:Get(100)
valfolder.Speed.Value = Speed:Get(16)
valfolder.CoinMultiplier.Value = Multiplier:Get(1)
valfolder.Rebirths.Value = Rebirths:Get(0)
valfolder.Gems.Value = Gems:Get(0)
valfolder.MapsOwned.Value = MapsOwned:Get(1)
game.ReplicatedStorage.Remotes.LoadMap:FireClient(plr, MapsOwned:Get(1))
for i, v in pairs(WeaponsOwned:Get({})) do
if v ~= "Iron Sword" then
local clone = game.ReplicatedStorage.GameItems.Weapons[v]:Clone()
clone.Parent = weaponsfolder
end
wait()
end
for i, v in pairs(PetsOwned:Get({})) do
local clone = game.ReplicatedStorage.GameItems.Pets[v]:Clone()
clone.Parent = petsfolder
end
wait()
end)
DataStores will throttle requests if there are too many of them, that is why you are getting this issue. Try to cut down the amount of requests by doing what @azahid1 described.
I’m attempting it however, i’m a bit stuck at the moment. I’m attempting to increment a value within the table within the datastore.
Basically here’s what im trying
–Main Data Script–
local datastore2 = require(script.Parent.DataStore2)
local MainKey = "DataStoreKey"
datastore2.Combine(MainKey, "Values")
local function SetDataTable()
local DefaultData = {
Values = {
["Coins"] = 0,
["Gems"] = 0,
["Experience"] = 0,
["Levels"] = 1,
["Points"] = 0,
["Defense"] = 100,
["Speed"] = 16,
["Multiplier"] = 1,
["Rebirths"] = 0,
["Maps"] = 1,}
}
return DefaultData
end
local UserData = datastore2(MainKey, plr):Get(SetDataTable())
local values = datastore2("Values", plr)
—enemy script—
local datastore2 = require(script.Parent.DataStore2)
humanoid.Died:Connect(function()
local UserData = datastore2(MainKey, plr):Get(SetDataTable())
local values = datastore2("Values", plr)
userdata.Values.Experience = userdata.Values.Experience + expgain
Values:Set(userdata.Values)
end)
however, this returns the error: Attempt to index field ‘Values’ a nil value.
Again i’m not good with datastores so i apologize in advance if this seems foolish.
I’m not sure what to do to fix it.
I am incrementing on the server, the enemy script is a serverscript, or do i need to increment using the same script rather than increment it in a seperate (enemy) script?