Hello everyone. I’m making a game and I want specific tools to save. I got this script online:
local Inventory = {}
local function Spawned(Char)
local Plr = game.Players:GetPlayerFromCharacter(Char)
for i,v in pairs(Inventory[Plr]) do
if Plr['Backpack']:findFirstChild(v.Name) then
Plr['Backpack'][v.Name]:Destroy()
end
v.Parent = Plr['Backpack']
end
Inventory[Plr] = {}
Char:WaitForChild('Humanoid').Died:connect(function()
for i,v in pairs({Plr['Backpack'], Char}) do
for ii,vv in pairs(v:GetChildren()) do
if vv:IsA('Tool') then
table.insert(Inventory[Plr], vv:Clone())
vv:Destroy()
end
end
end
end)
end
game.Players.PlayerAdded:connect(function(Plr)
Inventory[Plr] = {}
local Char = Plr.Character or Plr.CharacterAdded:wait()
Spawned(Char)
Plr.CharacterAdded:connect(Spawned)
end)
but there are some tools that duplicate because they are gamepass tools. I’m not 100% sure why they duplicate, but it’s a problem. If anyone could help me with this, it would be very appreciated!