Server-Client Communication
Last updated
Last updated
OVERDARE’s world operates based on communication between the server and the client.
The server manages the global state of the game and acts as the central system that handles communication with all clients (players).
The client is a local environment that runs on an individual player’s device, handling player input, visual effects, UI, and more.
Since the server and client operate independently, in a multiplayer game, game logic, camera control, and player input handling must be implemented and communicated using RemoteEvent.
Since the server and client have different functionalities, communication between them requires the use of RemoteEvent.
For example, GUI elements like buttons are processed only on the client-side, while game logic must be handled on the server-side. In other words, when a skill button click occurs on the client, it needs to send an event to the server to request that the server processes the skill usage logic.
RemoteEvent connects the roles of the server and client, enabling core interactions in multiplayer games.
Event sent from the sever to all clients
Server
Client
Game Over
Event sent from the server to a specific client
Server
Client
Display level-up UI on level-up
Event sent from the client to the server
Client
Server
Skill button click
RemoteEvent is an object provided to handle events between the server and client, supporting one-way communication.
For communication between the server and client, the RemoteEvent object must be accessible from both sides. To achieve this, RemoteEvent is placed in ReplicatedStorage, a storage where the server and client can share data. ReplicatedStorage safely synchronizes objects between the server and client, ensuring that the RemoteEvent is accessible in both environments.
You can send arguments along with events when firing a RemoteEvent. The arguments are passed when calling the FireServer, FireClient, or FireAllClients methods, and the receiving side can receive the data in a callback function.
The server sends an event to all clients. This is useful for synchronizing global game states or delivering the same information to all players.
In Script
In LocalScript
This method sends an event from the server to a specific client. It is used when handling tasks related to an individual player.
In Script
In LocalScript
This method sends an event from the client to the server. It is used when the server needs to handle the user’s input or specific events (e.g., button clicks, skill use requests).
In LocalScript
In Script
Since data sent from the client cannot be trusted, it should always be validated by the server.
Send only the necessary information to the server to reduce network load. (Send only minimal data from the client)
Avoid creating too many RemoteEvents. If tasks can be handled in the same context, process them using a single RemoteEvent.
Create RemoteEvent connections only when necessary, and disconnect when finished to avoid memory leaks. (Disconnect()
function)
When using a single RemoteEvent to handle multiple tasks, add the first argument (EventType) to indicate the task type. (Example of using EventType: PlayerActionType and ActionID)
💡 Tip. To clearly distinguish whether the RemoteEvent is for communication from the server to the client (Server to Client) or from the client to the server (Client to Server), it is recommended to use prefixes such as S2C_ for server-to-client communication and C2S_ for client-to-server communication. This makes the event’s role intuitive, enhancing code readability and maintainability.