If I disconnect a RemoteEvent.OnServerEvent connection in a server script, then fire the event after this disconnection, then reconnect a new RemoteEvent.OnServerEvent connection to the same RemoteEvent from the same server script, the connection immediately fires for the event I fired from the client whilst the connection was disconnected, and for any and all other events fired by the client during that time. What methods could I use to prevent this?
Hmm not sure what you mean. Can you clarify your problem?
Not sure why you’d want to do that but here’s a few simple solutions.
-
You could send a timestamp with the Remote and have another variable for timestamp upon connecting the Remote and only process the ones fired after that timestamp.
-
You can use string keys for Remotes in which will only process valid ones, if a key is a member of the dictionary with a function then run it
-
Use a different RemoteEvent
Think I’ve found the issue: when the client fires a RemoteEvent, the event is added to an ‘invocation queue’ if the server doesn’t immediately receive it. When OnServerEvent is reconnected server-side, the queue is cleared. I assume the solution would hence be to connect an empty function instead of disconnecting?