local function storeBackpack(client,inventory,inventory_folder)
for _, name in ipairs(inventory or { }) do
local tool = tools[name]
tool:Clone().Parent = client.Backpack -- For the player to use
tool:Clone().Parent = inventory_folder -- For saving and loading
end
end
Players.PlayerAdded:Connect(function(client)
if client:FindFirstChild('Character') ~= nil then
storeBackpack(client,inventory,inventory_folder)
end
client.CharacterAdded:Connect(function()
storeBackpack(client,inventory,inventory_folder)
end)
end)
It should be simple logic however whenever I’m trying to re arrange this arguement I still get double, none or a random pick in the script. Is there any arrangement that would help?
if you want to keep tools when the player dies
clone the tool into startergear and the backpack, on death the item will spawn back into the backpack
local function storeBackpack(client,inventory,inventory_folder)
for _, name in ipairs(inventory or { }) do
local tool = tools[name]
tool:Clone().Parent = client.Backpack -- For the player to use
tool:Clone().Parent = client.StarterGear
tool:Clone().Parent = inventory_folder -- For saving and loading
end
end
humanoid.died:
grab all tools from backpack and character into array and parent to nil
plr:Getpropertychangedsignal(“Character”):Wait()
Move all tools to a player’s backpack
It’s a bit complicated… this script is showing the basic concept. link At least one way of doing it.
Create a “list” (array) of tools they have and save it, then clone that list back when they respawn.
This is very clearly the easiest and bestway to do this in my position. Specifically because I had a save system for items, it made it less of a hastle. Thank you <3
For anyone else who has the same problem, but doesnt have a inventory system like mine. You can save and remove items from starter gear through different strategies.
I have one… (Sorry I misunderstood your question)
Packback
--Packback ServerScript
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local packback = Instance.new("Folder")
packback.Name = "Packback"
packback.Parent = player
player.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
for _, tool in pairs(packback:GetChildren()) do
tool:Clone().Parent=player.Backpack
end packback:ClearAllChildren()
humanoid.Died:Connect(function()humanoid:UnequipTools()
for _, tool in pairs(player.Backpack:GetChildren())do
if tool:IsA("Tool") then
tool:Clone().Parent=packback
end
end
end)
end)
end)