Everything it works, and it’s Printing the First tool saving, but once it’s time to add to the folder the stuff, it says this: 16:36:55.837 - ServerScriptService.Car Handler:36: bad argument #1 to ‘pairs’ (table expected, got no value)
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function()
local Character = Player.Character or Player.CharacterAdded:Wait()
Character:WaitForChild("Humanoid").Seated:Connect(function(IsSeated, WhatSeat)
if IsSeated then
if WhatSeat.Name == "DriveSeat" then
if Player.Backpack:FindFirstChild("HK416") then
Player.Backpack:FindFirstChild("HK416"):Destroy()
end
end
end
end) --Load
end)
local Folder = Instance.new("Folder", game.ServerStorage)
Folder.Name = Player.Name.."-Trunk"
local success = pcall(function()
local data = Data:GetAsync(Player.UserId.."-Trunk")
end)
if success then
print("Hi")
for i,v in pairs(Data:GetAsync(Player.UserId.."-Trunk") ) do
if v[1] then
local Folder2 = Instance.new("Folder", Folder)
Folder2.Name = v[1]
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
local StuffToSave = {}
for i,v in ipairs(game.ServerStorage:FindFirstChild(Player.Name.."-Trunk"):GetChildren()) do
table.insert(StuffToSave, {v.Name})
print("Saved "..v.Name)
end
game.ServerStorage:FindFirstChild(Player.Name.."-Trunk"):Destroy()
if StuffToSave[1] then
print(StuffToSave[1])
end
Data:SetAsync(Player.UserId.."-Trunk", StuffToSave)
end)