16:55:00.942 - Argument 2 missing or nil 16:55:00.943 - Stack Begin 16:55:00.943 - Script 'ServerScriptService.toolSave', Line 103 16:55:00.943 - Stack End
This script is suppose to save the tools in the backpack for next time the player joins again
local rs = game:GetService("ServerStorage")
local ds = game:GetService("DataStoreService")
local store = ds:GetDataStore("saveStore")
local shopItems = rs:WaitForChild("ShopItems")
--< directory functions
local dir = {}
local function edit(player, list)
dir[player.Name] = list
end
local function setup(player, list)
for i = 1, #list do
local tool = shopItems:FindFirstChild(list[i])
if tool then
local clone = tool:Clone()
clone.Parent = player.Backpack
else
print(list[i] .. " not found")
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
char.Humanoid.Died:connect(function()
char.Humanoid:UnequipTools()
local old = player.StarterGear:GetChildren()
for i = 1, #old do
old[i]:Destroy()
end
local new = player.Backpack:GetChildren()
for i = 1, #new do
new[i]:Destroy()
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)
-- safety
game:BindToClose(function()
wait(5)
end)

3 comments
What's with everyone following tutorials, Shiroos code is bad
I literally finished a Tool Persistence remake for someone, use mine: https://pastebin.com/TqM0Y6W9. Ensure you put a Folder within ServerStorage called Tools with all the tools you wish to have saved
I tried other tutorials to do the same thing but they also didn't work