Weird thing happens when I click on TextButton again

So, I am making an inventory system and whenever I want to take the item back out and put it back in, this happens:


Here’s the script:

local plrs = game:GetService("Players")

local tween = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(0.7)

local GUI = script.Parent

local plr = plrs.LocalPlayer or plrs.PlayerAdded:Wait()

local char = plr.Character or plr.CharacterAdded:Wait()

local inventory = plr:WaitForChild("Backpack")

local mouse = plr:GetMouse()

mouse.KeyDown:Connect(function(key)
	if key == "m" then
		print("Pressed M.")
		GUI.Enabled = not GUI.Enabled
	end
end)

for _,v in pairs(GUI:GetChildren()) do
	if v:IsA("TextButton") then
		print("TextButton found: " .. v.Name)
		v.MouseEnter:Connect(function()
			local tweenTrack = tween:Create(v,tweenInfo,{["Size"] = UDim2.new(0,166,0,125)})
			tweenTrack:Play()
			v.MouseLeave:Connect(function()
				local newTweenTrack = tween:Create(v,tweenInfo,{["Size"] = UDim2.new(0, 148, 0, 108)})
				newTweenTrack:Play()
			end)
			v.MouseButton1Click:Connect(function()
				for _,tools in pairs(char:GetChildren()) do
					if tools:IsA("Tool") then
						print("Tool equipped: Mouse clicked.")
						tools.Parent = game:GetService("ReplicatedStorage")
						v.Text = tools.Name
						v.MouseButton1Click:Connect(function()
							tools.Parent = inventory
							v.Text = v.Name
						end)
					end
				end
			end)
		end)
	end
end

Help is hugely appreciated!

You could try taking the MouseLeave and MouseButtone1Click connections out of the MouseEnter connections, so you don’t make new connections every time MouseEnter fires.

v.MouseEnter:Connect(function()
	local tweenTrack = tween:Create(v,tweenInfo,{["Size"] = UDim2.new(0,166,0,125)})
	tweenTrack:Play()
end)

v.MouseLeave:Connect(function()
	local newTweenTrack = tween:Create(v,tweenInfo,{["Size"] = UDim2.new(0, 148, 0, 108)})
	newTweenTrack:Play()
end)

v.MouseButton1Click:Connect(function()
	for _,tools in pairs(char:GetChildren()) do
		if tools:IsA("Tool") then
			print("Tool equipped: Mouse clicked.")
			tools.Parent = game:GetService("ReplicatedStorage")
			v.Text = tools.Name
			tools.Parent = inventory
			v.Text = v.Name
		end
	end
end)

The TextButton does not store the item anymore. Any other solutions?