Tools are cloning when I die how do I fix

this is a server sided script I want it to take the tools away when the get damaged which it does

but when they die it keeps the tools in the folder which means whenever they get damaged again they get double the tools

–
script

local function onPlayerAdded(plr)

local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")

	local function onDied(folder)
		print(plr.Name, "has died!")
		local folder = game.ServerStorage:WaitForChild("PlayerStorage"):FindFirstChild(plr.Name.. "` Folder") or Instance.new("Folder")
		folder.Name = plr.Name.. "` Folder"
		folder.Parent = game:GetService("ServerStorage"):WaitForChild("PlayerStorage")
		
		for i , v in pairs(folder:GetChildren()) do
			v:Destroy()
		end
	end

	humanoid.Died:Connect(onDied)
end

plr.CharacterAdded:Connect(onCharacterAdded)

end

Players.PlayerAdded:Connect(onPlayerAdded)

it might be not working because you are creating a function inside a function. I would suggest making them seperatly.