Hi.
Im experiencing an error with my tool datastore, which makes it break with the output error “Argument 1 missing or nil” when loading backpack, and “Argument 2 missing or nil” when saving.
Loading:
Saving:
Its weird bcuz i didnt even modified it, i was editing other things when that error appeared. I used a text comparer to compare that script with an older one and no changes, they were the same. I thought it was a studio only error, but in-game happened too. And it was working without problems some hours ago
Heres the script. Its located in ServerScriptService, tools are directly in ServerStorage
local ds = game:GetService("DataStoreService")
local store = ds:GetDataStore("ArmasXD")
local library = game.ServerStorage
local dir = {}
local function edit(player, list)
dir[player.Name] = list
end
local function setup(player, list)
for i = 1, #list do
local tool = library:FindFirstChild(list[i])
if tool then
local clone = tool:Clone()
local clone2 = tool:Clone()
clone.Parent = player.Backpack
clone2.Parent = player.StarterGear
else
end
end
end
game.Players.PlayerAdded:connect(function(player)
local ready = false
player.CharacterAdded:connect(function(char)
local bp = player.Backpack
local data = nil
if ready == false then
ready = true
data = store:GetAsync(player.UserId)
if data then
setup(player, data)
edit(player, data)
end
end
local count = 0
local function adjust()
if char.Humanoid.Health > 0 then
local list = {}
local equipped = char:FindFirstChildOfClass("Tool")
if equipped then
table.insert(list, equipped.Name)
end
local tools = bp:GetChildren()
for i = 1, #tools do
table.insert(list, tools[i].Name)
end
if count ~= #list then
edit(player, list)
count = #list
end
end
end
bp.ChildAdded:connect(adjust)
bp.ChildRemoved:connect(adjust)
char.ChildAdded:connect(function(child)
if child.ClassName == "Tool" then
adjust()
end
end)
char.ChildRemoved:connect(function(child)
if child.ClassName == "Tool" then
adjust()
end
end)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
store:SetAsync(player.UserId, dir[player.Name])
dir[player.Name] = nil
end)
game:BindToClose(function()
wait(3.5)
end)
If you need any other info feel free to ask me, thanks and have a great day/night.