function guiOpen()
if (guiGetVisible(YOURGUI) == true) then --Check whether gui is visible or not
guiSetVisible(YOURGUI, false) --if visible then close it
else
guiSetVisible(YOURGUI, true) --if not open it
end
end
bindKey("F2", "down", guiOpen) --bind F2 for that function
Replace YOURGUI with your gui.
This is a client side script.