Why does it only save one tool?
local SavedTools = game.ReplicatedStorage:WaitForChild("SavedTools")
local Datastore = game:GetService("DataStoreService")
local ToolData = Datastore:GetDataStore("ToolData")
game.Players.PlayerAdded:Connect(function(plr)
local ToolData = ToolData:GetAsync(plr.UserId)
local BackPack = plr:WaitForChild("Backpack")
local StarterGear = plr:WaitForChild("StarterGear")
if ToolData ~= nil then
for _,v in pairs(ToolData) do
if SavedTools:FindFirstChild(v) and BackPack:FindFirstChild(v) == nil and StarterGear:FindFirstChild(v) == nil then
SavedTools[v].Parent = BackPack
SavedTools[v].Parent = StarterGear
end
end
end
plr.CharacterRemoving:Connect(function(character)
character:WaitForChild("Humanoid"):UnequipTools()
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
local ToolTable = {}
for _,v in pairs(plr.Backpack:GetChildren()) do
table.insert(ToolTable, v.Name)
end
if ToolTable ~= nil then
ToolData:SetAsync(plr.UserId, ToolTable)
end
end)