Item copied on death by item save script

An item that player receives after a round in my game starts is being doubled by a tool saving scrippt after they die, it’s quite problematic as it fills up the player inventory, the script was made by Shiro75.

There is a folder called library which is where the items player gets back after dying are supposed to be (atleast that’s what I think), and the item which is the standard weapon, called Rocket, is not in this folder but somehow it is still given back to you after death, so not only you have a weapon in the lobby where you are not supposed to have one, you also get a second weapon after the round starts.

I really hope someone can help me out with upgrading this script so it will only take items from the Library folder, or somehow blacklist the weapon I don’t want players to get back after dying, I’d be really happy if anyone could help me.

local rs = game:GetService("ReplicatedStorage")
local ds = game:GetService("DataStoreService")
local store = ds:GetDataStore("saveStore")
local library = rs:WaitForChild("Library")

--< directory functions

local dir = {}

local function edit(player, list)
	dir[player.Name] = list
end

local function setup(player, list)
	for i = 1, #list do
		local tool = library:FindFirstChild(list[i])
		if tool then
			local clone = tool:Clone()
			clone.Parent = player.Backpack
		else
			print(list[i] .. " not found")
		end
	end
end

--< player events

game.Players.PlayerAdded:connect(function(player)

local ready = false

	player.CharacterAdded:connect(function(char)

	local bp = player.Backpack
	local data = nil
	
	if ready == false then
		ready = true
		
		data = store:GetAsync(player.UserId)
		
		if data then
			setup(player, data)
			edit(player, data)
		end
	end	
	
	char.Humanoid.Died:connect(function()
		char.Humanoid:UnequipTools()
		
		local old = player.StarterGear:GetChildren()
		for i = 1, #old do
			old[i]:Destroy()
		end
		
		local new = player.Backpack:GetChildren()
		for i = 1, #new do
			new[i].Parent = player.StarterGear
		end		
	end)	
	
	--< adjuster
	
	local count = 0
	
	local function adjust()
		
	if char.Humanoid.Health > 0 then
	
		local list = {}
	
		local equipped = char:FindFirstChildOfClass("Tool")
		if equipped then
			table.insert(list, equipped.Name)
		end	
	
		local tools = bp:GetChildren()
		for i = 1, #tools do
			table.insert(list, tools[i].Name)
		end
	
		if count ~= #list then
			edit(player, list)
			count = #list
		end
	end
	end
	
	--< child events
	
	bp.ChildAdded:connect(adjust)	
	bp.ChildRemoved:connect(adjust)	
	
	char.ChildAdded:connect(function(child)
		if child.ClassName == "Tool" then
			adjust()
		end
	end)
	
	char.ChildRemoved:connect(function(child)
		if child.ClassName == "Tool" then
			adjust()
		end
	end)	
	
	end)
end)

game.Players.PlayerRemoving:connect(function(player)
	store:SetAsync(player.UserId, dir[player.Name])
	dir[player.Name] = nil
end)

--< safety

game:BindToClose(function()
	wait(5)
end)

try making a script that detects whenever there are two of the same item in your inventory and when there is it destroys the other item leaving only one

It would help with preventing players from having more than one item, but they could still have the weapon in the lobby.