Need help with inventory wheel

Hi! I’m making stylized inventory wheel. The thing is, I scripted almost everything in it but I don’t know how to script one thing. I want the player to have only one weapon that he equipped last and delete other weapons in his inventory.

All weapons are in Replicated Storage of course.
Also I would appreciate any corrections in my code.

local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://11825958589"
sound.Parent = script.Parent:WaitForChild("SoundEffects")

local Name = script.Parent:WaitForChild("Name")
Name.Visible = false

local Selected = false

local Selection = script.Parent:WaitForChild("Selection")
local RS = game:GetService("ReplicatedStorage")
local Weapons = RS:WaitForChild("Weapons")

for _, plr in pairs(game.Players:GetPlayers()) do
	for _, Select in pairs(Selection:GetDescendants()) do
		if Select:IsA("ImageButton") then
			Select.MouseEnter:Connect(
				function()
					sound:Play()
					
					if Selected == false then
						Select.ImageColor3 = Color3.new(0.176471, 0.431373, 0.72549)
						Selected = true
					end

					for _, Icon in pairs(Select:GetDescendants()) do
						Name.Visible = true
						Name.Text = Icon.Name

						local tool = Weapons:FindFirstChild(Icon.Name)
						
						local char = plr.Character or plr.CharacterAdded:Wait()
						local hum = char:FindFirstChildOfClass("Humanoid")
						hum:UnequipTools()
						
						if Icon.Name == "Fist" then
							return
						else
							if plr.Backpack:FindFirstChild(Icon.Name) then
								return
							else
								coroutine.wrap(
									function()
										local t = tool:Clone()
										t.Parent = plr.Backpack
										hum:EquipTool(t)
									end)()
							end
							
						end
					end
				end)

			Select.MouseLeave:Connect(
				function()
					if Selected == true then
						Select.ImageColor3 = Color3.new(0.0470588, 0.0470588, 0.0470588)
						Selected = false		
					end
				end)
		end
	end
end


You could detect whenever there’s a tool added in their backpack and then store that into a variable. Like this:

local MostRecentTool
...Backpack.ChildAdded:Connect(function(child)
    if child:IsA("Tool") then
        child.Equipped:Connect(function()
            MostRecentTool = child
        end)
    end
end)

The variable will update everytime the player equips a tool.
You could also just use .ChildRemoved() as the tool gets parented under the player’s character when they equip it but it’s your choice.