Can’t you just make a connection outside of the binding to the function?
ContextActionService:BindAction("BindOne", FunctionOne, false, Enum.KeyCode.One, --[[any other inputs to bind]])
Button1.MouseButton1Click:Connect(FunctionOne) --or any other event
Just disconnect the connection when unbinding, or make the button invisible. I don’t think there’s a way to add GUI object events to a ContextActionService bind.
Someone please correct me if I’m wrong, I’m not 100% sure.
I was reading the docs on connecting / disconnecting functions.
It looks like there is no reason to connect / disconnect unless you just don’t want the function to run the next time the button or quick key is pressed.
It says all player connections are removed when the player leaves the game. And, it doesn’t say that a new connection is made every time the player presses a button or a quick key. (My area of misunderstanding.)
The connection is only established one time and it kept open until deliberately disconnected.
Connect functions when you need, disconnect them when you don’t need. ALWAYS disconnect functions when you don’t need them anymore, exept only 2 cases:
Instance which did connection destroyed
Connection should be permanent.
Otherwise, every connected function will consume memory, cause lags, and will be memory leak reason.
The documentation says nothing about memory leaks.
It only makes one mention of disconnecting functions:
If you connect a function to an event but don’t want the function called in subsequent event firings, disconnect it from the event by calling Disconnect()