Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to get a duplicate gear remover?

Asked by 3 years ago

I'm having a problem with my dupe gear remover. I have a sword fight arena, and it gives me 2 swords when i step into it and that is a problem for me. (I'm kinda a perfectionist and it also causes problems with double lunging). I have the code here, but it seems to clear both swords and not all but one.

 local tmpTable = {} -- store items names

 for I,v in pairs(player.Backpack:GetChildren()) do --  loop through all items found

    if  tmpTable [v.Name] ~= nil then -- checks if item exists in the list

        print("a duplicate has been found") -- found item e.g. a duplicate

 v:Destroy() -- deletes tool

    else

        tmpTable [v.Name]  = "a"  -- we don't need to use the value we are only using the key

        print("item added to list")


end

1 answer

Log in to vote
0
Answered by 3 years ago
v:Destroy() -- deletes tool
tmpTable[v.Name]=nil
else
0
Thanks! I'm a begginer scripter and i was wondering how to do this. where would i put that script in my code, like what line epic_hen9 27 — 3y
Ad

Answer this question