Hello! It look like it’s not saving correctly, Any idea? It’s printing table before the :SetAsync() and all tools, but it’s not creating the folder and place it on Trunk Player folder on server storage! Help
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").Parent = game.ServerStorage:FindFirstChild(Player.Name.."-Trunk")
end
end --Backpack
end
end) --Load2
end)
local Folder = Instance.new("Folder", game.ServerStorage)
Folder.Name = Player.Name.."-Trunk"
local success,data = pcall(function()
return Data:GetAsync(Player.UserId.."-Trunk")
end)
if success and data then
print("Hi")
for i,v in pairs(data) do
print(v[1])
local Folder2 = Instance.new("Folder", Folder)
Folder2.Name = v[1]
Folder2.Parent = Folder
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)
game.ReplicatedStorage.EventsFolder.MoveTool.OnServerEvent:Connect(function(Player, ToolName)
if Player.Backpack:FindFirstChild(ToolName) then
if game.ServerStorage:FindFirstChild(Player.Name.."-Trunk"):FindFirstChild(ToolName) then
game.ServerStorage:FindFirstChild(Player.Name.."-Trunk"):FindFirstChild(ToolName):Destroy()
end
local Folder = Instance.new("Folder")
Folder.Name = ToolName
Folder.Parent = game.ServerStorage:FindFirstChild(Player.Name.."-Trunk")
print("Added")
Player.Backpack:FindFirstChild(ToolName):Destroy()
game.ReplicatedStorage.EventsFolder.Load:FireClient(Player, ToolName)
end
end)
game.ReplicatedStorage.EventsFolder.Tool.OnServerEvent:Connect(function(Player, NameOfTool)
if game.ServerStorage:FindFirstChild(Player.Name.."-Trunk"):FindFirstChild(NameOfTool) then
game.ServerStorage:FindFirstChild(NameOfTool):Clone().Parent = Player.Backpack
if game.ServerStorage:FindFirstChild(Player.Name.."-Trunk"):FindFirstChild(NameOfTool) then
game.ServerStorage:FindFirstChild(Player.Name.."-Trunk"):FindFirstChild(NameOfTool):Destroy()
end
print("Ok")
end
end)