I have a GUI that appears for certain players by using Remote Events, and after appearin, the text of the GUI changes every few seconds.
I would like some kind of event on the server-side to occur when everything on the client-side ends for all of the certain players.
How would I make a script on the server side that waits for all client events to end?
Sorry if my explanation is difficult to understand. Please ask me questions if you are unsure of anything.
I have a cutscene system in my project that does this, as in it waits for all players to finish the cutscene on their end before proceeding with any further game actions. This requires server → client → server communication with a little bit of client reliance. You can set an expiry time on the server so that it’s not completely client authoritative and so you can avoid hanging the server due to unresponsive clients.
First element is server → client. The server tells the client that it needs to do something; play a cutscene, run some dialogue, whatever. It then also tracks all the players who have been asked to run that content on their end and waits until they’ve responded through a tracking table. This is where the next part comes in, client → server.
The second element is client → server. The client will do what it needs to do on its end to execute the task as instructed by the server. When the client is finished, it will fire a RemoteEvent telling the server that it finished and then the player’s name will be added to the server’s tracking table. This only needs to happen once so you can sink any further attempts by that player to call the remote (e.g. an exploiter spamming data to it, even though you don’t quite need any parameters). You’re done there.
Now at the end of all of this, the server needs to confirm that all the players it instructed to execute a certain task have responded that they completed it. Don’t let clients be completely authoritative though because a bug or an exploiter may prevent the event from firing, thus not informing the server that they are finished and causing the server to hang. Have the server define a certain time limit to which all clients need to finish up running the task on their end. If this time limit is passed then have the server assume everyone’s ready to go and proceed with anything you need to do on the server.