local R={}function WeldTool.Equip()ShowUI()EnableFocusHighlighting()end function WeldTool.Unequip()HideUI()ClearConnections()end function ClearConnections()for u,l in pairs(R)do l:Disconnect()R[u]=nil end end function ShowUI()if UI then UI.Visible=true return end UI=Core.Tool.Interfaces.BTWeldToolGUI:Clone()UI.Parent=Core.UI UI.Visible=true UI.Interface.WeldButton.MouseButton1Click:Connect(CreateWelds)UI.Interface.BreakWeldsButton.MouseButton1Click:Connect(BreakWelds)local R=(UI:WaitForChild("\084\105\116\108\101")):WaitForChild("\083\105\103\110\097\116\117\114\101")ListenForManualWindowTrigger(WeldTool.ManualText,WeldTool.Color.Color,R)end function HideUI()if not UI then return end UI.Visible=false end

local Connections = {};

function WeldTool.Equip()
	-- Enables the tool's equipped functionality

	-- Start up our interface
	ShowUI();
	EnableFocusHighlighting();

end;

function WeldTool.Unequip()
	-- Disables the tool's equipped functionality

	-- Clear unnecessary resources
	HideUI();
	ClearConnections();

end;

function ClearConnections()
	-- Clears out temporary connections

	for ConnectionKey, Connection in pairs(Connections) do
		Connection:Disconnect();
		Connections[ConnectionKey] = nil;
	end;

end;

function ShowUI()
	-- Creates and reveals the UI

	-- Reveal UI if already created
	if UI then

		-- Reveal the UI
		UI.Visible = true;

		-- Skip UI creation
		return;

	end;

	-- Create the UI
	UI = Core.Tool.Interfaces.BTWeldToolGUI:Clone();
	UI.Parent = Core.UI;
	UI.Visible = true;

	-- Hook up the buttons
	UI.Interface.WeldButton.MouseButton1Click:Connect(CreateWelds);
	UI.Interface.BreakWeldsButton.MouseButton1Click:Connect(BreakWelds);

	-- Hook up manual triggering
	local SignatureButton = UI:WaitForChild('Title'):WaitForChild('Signature')
	ListenForManualWindowTrigger(WeldTool.ManualText, WeldTool.Color.Color, SignatureButton)

end;

function HideUI()
	-- Hides the tool UI

	-- Make sure there's a UI
	if not UI then
		return;
	end;

	-- Hide the UI
	UI.Visible = false;

end;
