Remove = function(self,Tool) for i, v in ipairs(Spots) do print(v, Tool, i, Current) if v == Tool and tonumber(Current) == tonumber(i) then Spots[i] = true script.Parent:FindFirstChild(i).IMG.Image = "" break end end print("--------------------------------") end
Output
ClassicSword ClassicSword 1 2 ClassicSword ClassicSword 2 2 -- MATCH true ClassicSword 3 2 true ClassicSword 4 2 true ClassicSword 5 2 --------------------------------
In this script, it gets the tools name, but to make the inventory more precise, it also checks the current tool you're holding. As you can see in the output, there was a match, both if statements were fulfilled. But it ignored that and went on. Why does it do this?
Also, spots is just a directory of free spots inside the inventory.
Spots = { [1] = true; [2] = true; [3] = true; [4] = true; [5] = true; }