PianoKeysConnections={}ExitButtonConnection=nil SheetsButtonConnection=nil SheetsEditedConnection=nil CapsButtonConnection=nil function MakeGuiConnections()for f,S in pairs(PianoGui.Keys:GetChildren())do PianoKeysConnections[f]=S.InputBegan:connect(function(f)PianoKeyPressed(f,tonumber(S.Name))end)end ExitButtonConnection=PianoGui.ExitButton.InputBegan:connect(ExitButtonPressed)SheetsButtonConnection=PianoGui.SheetsButton.InputBegan:connect(SheetsButtonPressed)SheetsEditedConnection=SheetsGui.Sheet.ScrollingFrame.TextBox.Changed:connect(SheetsEdited)CapsButtonConnection=PianoGui.CapsButton.InputBegan:connect(CapsButtonPressed)end function BreakGuiConnections()for f,S in pairs(PianoKeysConnections)do S:disconnect()end ExitButtonConnection:disconnect()SheetsButtonConnection:disconnect()SheetsEditedConnection:disconnect()CapsButtonConnection:disconnect()end
----------------------------------
-----------CONNECTIONS------------
----------------------------------

PianoKeysConnections = {}
ExitButtonConnection = nil
SheetsButtonConnection = nil
SheetsEditedConnection = nil
CapsButtonConnection = nil

function MakeGuiConnections()
	for i, v in pairs(PianoGui.Keys:GetChildren()) do
		PianoKeysConnections[i] = v.InputBegan:connect(function(Object)
			PianoKeyPressed(Object, tonumber(v.Name))
		end)
	end

	ExitButtonConnection = PianoGui.ExitButton.InputBegan:connect(ExitButtonPressed)
	SheetsButtonConnection = PianoGui.SheetsButton.InputBegan:connect(SheetsButtonPressed)
	SheetsEditedConnection = SheetsGui.Sheet.ScrollingFrame.TextBox.Changed:connect(SheetsEdited)
	CapsButtonConnection = PianoGui.CapsButton.InputBegan:connect(CapsButtonPressed)
end
function BreakGuiConnections()
	for i, v in pairs(PianoKeysConnections) do
		v:disconnect()
	end

	ExitButtonConnection:disconnect()
	SheetsButtonConnection:disconnect()
	SheetsEditedConnection:disconnect()
	CapsButtonConnection:disconnect()
end
