Open Sourced Inventory/Backpack system

How would I make it so that the inventory numbers would reset when a tool leaves the inventory? Right now I’m using a menu to choose a loadout and when the loadout is chosen, any items in the inventory are destroyed. The number key for the inventory doesn’t reset, Ex. I have 2 tools and reset the inventory with another tool, instead of becoming 1 the tool can be equipped with 3

Just put a delay before giving the tool. Something like

for i,v in ipairs(Player.Backpack:GetChildren()) do
    if v:IsA("Tool") then
        v:Destroy()
    end
end

if Player.Character and Player.Character:FindFirstChildOfClass("Tool") then
    Player.Character:FindFirstChildOfClass("Tool"):Destroy()
end

wait(2)

for i,v in ipairs(Tools) do
    v:Clone().Parent = Player.Backpack
end

untested code