Detecting Duplicate Tools

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Want tools with the same name deleted and only keep 1
  2. What is the issue? Include screenshots / videos if possible!
    Either something is wrong or its not detecting same tool name
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried using client side and I can’t make it add a loop where it detects every time a new tool is added
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
game.Players.PlayerAdded:connect(function(Player)
    Player.Backpack.ChildAdded:connect(function(Child)
        for i,v in pairs(Player.Backpack:GetChildren()) do
            if not v == Child and v.Name == Child.Name then
                Child:Destroy()
            end
        end
    end)
end)
1 Like

How are you running into a scenario where you are getting a duplicate tool? I find it would be wiser to just not give the player a tool if they already have it. You can track what tools a player owns externally or directly by checking their backpack and character.

This code itself won’t work as intended because it’s not tracking tools of a previous iteration and removing if it’s iterated over something of the same name and because the Backpack instance gets destroyed rather than cleared whenever the player dies, therefore the ChildAdded connection only gets established for the first backpack and none afterwards.

1 Like