-- Set up the event handlers for the Close TextButtons in the windows

for _, window in ipairs(gui:GetChildren()) do
	if window:IsA("Frame") then
		local closeButton = window:FindFirstChild("Close")
		if closeButton and closeButton:IsA("TextButton") then
			closeButton.MouseButton1Click:Connect(function()
				openGui.Visible = true
				window:TweenSizeAndPosition(
					UDim2.new(1, 0, 0.022, 0),
					UDim2.new(0.0, 0, 0.978, 0),
					'Out',
					'Quad',
					0.2,
					false,
					function()
						window.Visible = false
					end
				)
			end)
		end
	end
end

