Hi, I'm trying to make a datastore that stores values with weapons name on it. I put these values in a different folder instead of backpack is because I'm letting the player access it in another way. This is what I got after reading post on the roblox devforum, watching videos and looking at the developer.roblox.com page. I've seen on the devforum that they suggest that I should use Datastore2 but I'm not sure if it work for my issue. They also told me to use UpdateAsync in my datastore script to reduce the risk of losing data but I'm not sure how to apply it to my script as they only have examples with numbers. I've tried this script and it work fine but after 3 try, 2 of the try lost one of the weapon value in the in the PlrWeapons folder and there was this error " DataStore request was added to queue. If request queue fills, further requests will be dropped. Try sending fewer requests.Key = 185862361".
local datastore = game:GetService("DataStoreService"):GetDataStore("WeaponStorage")
local rep = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(plr)
local chest = Instance.new("Folder")
chest.Parent = plr
chest.Name = "PlrWeapons"
local stat
local success , erro = pcall(function()
stat = datastore:GetAsync(plr.UserId)
end)
if stat and success then
for i,v in pairs(stat) do
pcall(function()
if rep.Weapons:FindFirstChild(v)then
local tag = Instance.new("BoolValue")
tag.Parent = chest
tag.Name = v
end
end)
end
else
local tag = Instance.new("BoolValue")
local tag2 = Instance.new("BoolValue")
local tag3 = Instance.new("BoolValue")
tag.Name = "WoodenSword"
tag2.Name = "WoodenSpear"
tag3.Name = "WoodenBow"
tag.Parent = chest
tag2.Parent = chest
tag3.Parent = chest
end
chest.ChildAdded:Connect(function()
local weapons = {}
for i,v in pairs(plr.PlrWeapons:GetChildren())do
table.insert(weapons, v.Name)
end
local success, err = pcall(function()
datastore:SetAsync(plr.Id, weapons)
end)
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local weapons = {}
for i,v in pairs(plr.PlrWeapons:GetChildren())do
table.insert(weapons, v.Name)
end
local success, err = pcall(function()
datastore:SetAsync(plr.UserId, weapons)
end)
if err then
warn(err)
end
end)
game:BindToClose(function()
for i, plr in pairs(game.Players:GetPlayers()) do
local weapons = {}
for i,v in pairs(plr.PlrWeapons:GetChildren())do
table.insert(weapons, v.Name)
end
local success, err = pcall(function()
datastore:SetAsync(plr.UserId, weapons)
end)
if err then
warn(err)
end
end
end)
Please help me as this would help me make datastore for other strings in my game. Thank you!

1 comment
You may wish to look into https://devforum.roblox.com/t/save-your-player-data-with-profileservice-datastore-module/667805 which can help with preventing data loss