How do I disconnect a connection, then re-connect the connection each time a player performs a specific action?

I’m trying to get it to where if a player presses “E” for example, it fires to the server onto a remote event and establishes a connection through :Connect(). This remote event then tells the server to perform an action, and after the action is performed, it then :Disconnect()'s the connection. BUT I’m looking to get it to where if I were to press E again, it would then re-connect the connection and perform the action again.

So far though, it just disconnects and does not re-connect nor perform the action again if I press E again. I’ve tried looking into re-connecting connections and so far nothing has helped my case.

Any help would be immensely appreciated. (I am a beginner so apologies if some things I say sound uninformed)

1 Like

You can just store the connection in a dictionary with the key being the player that fired it.

To avoid the re-connect check the dictionary if the connection is already made then proceed to handle it.

2 Likes

Could you show your code?

(chars)

1 Like

I’ll be able to tomorrow, currently not at my computer right now to grab the code. Thank you for the reply on the other post as well.

1 Like

Sorry, I don’t think I’m in need of the re-connecting thing anymore. Thank you for your willingness to help nevertheless.

Also if possible, could I get your insight on this matter here? Would having players mass use one server-sided script lag the server?