How to pass a value from a connection to a function?

Hi, I was optimizing my scripts but I was delayed by a certain problem.

What I want to achieve is passing a value from one connection to multiple functions without writing multiple connections to each function.

short script:

local Buttons = {
	Main.B_Menu,
	-- More buttons
}

function DestroyLine(B)
	B:FindFirstChild("Line"):Destroy()
end

function MouseLeaves(B)
	DestroyLine(Buttons[B])
end

Buttons[1].MouseLeave:Connect(MouseLeaves(1))

error:

< Error > Attempt to connect failed: Passed value is not a function

Thanks for any help!

in case you don’t understand here is the complete script:

local Main = script.Parent
local Frames = Main.Parent.Parent
local SFold = script.Sounds

-- Local Groups

local Sounds = {
	SFold.Click,
	SFold.Hover,
}

local UIs = {
	Frames.F_HP,
	Frames.F_VH,
	Frames.F_HM,
	Frames.F_NIS,
	Frames.F_OP,
	Frames.F_PR,
	--?
}

local Buttons = {
	Main.B_HP,
	Main.B_VH,
	Main.B_HM,
	Main.B_NIS,
	Main.B_OP,
	Main.B_PR,
	--More buttons!
}

-- Functions

function NewLine(B)
	local Line = Instance.new("Frame")
	Line.Name = "Line"
	Line.AnchorPoint = Vector2.new(.5,0)
	Line.BorderMode = Enum.BorderMode.Inset
	Line.BorderSizePixel = 0
	Line.Position = UDim2.fromScale(0.5,1)
	Line.Size = UDim2.new(0,0,0,2)
	Line.Parent = B
	Line:TweenSize(UDim2.new(1.2,0,0,2),Enum.EasingDirection.In,Enum.EasingStyle.Quad,.2)
end

function DestroyLine(B)
	B:FindFirstChild("Line"):Destroy()
end

function MouseEnters(B)
	Sounds[2]:Play()
	NewLine(Buttons[B])
end

function MouseLeaves(B)
	DestroyLine(Buttons[B])
end

-- MouseEnter
Buttons[1].MouseEnter:Connect(MouseEnters(1))
Buttons[2].MouseEnter:Connect(MouseEnters(2))
Buttons[3].MouseEnter:Connect(MouseEnters(3))
Buttons[4].MouseEnter:Connect(MouseEnters(4))
Buttons[5].MouseEnter:Connect(MouseEnters(5))
Buttons[6].MouseEnter:Connect(MouseEnters(6))
-- MouseLeave
Buttons[1].MouseLeave:Connect(MouseLeaves(1))
Buttons[2].MouseLeave:Connect(MouseLeaves(2))
Buttons[3].MouseLeave:Connect(MouseLeaves(3))
Buttons[4].MouseLeave:Connect(MouseLeaves(4))
Buttons[5].MouseLeave:Connect(MouseLeaves(5))
Buttons[6].MouseLeave:Connect(MouseLeaves(6))

Try something like this:

local buttons = {}

for idx, button in pairs(buttons) do
	button.MouseLeave:Connect(function()
		DestroyLine(buttons[idx])
	end)
end

What I am doing here is looping through all the buttons, which will easily let me receive the event of each button.