Server-Client Communication
Overview
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 or RemoteFunction.
Types of Communication
Since the server and client have different functionalities, communication between them requires the use of RemoteEvent or RemoteFunction.
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.
These objects connect the roles of the server and client, enabling core interactions in multiplayer games.
Event sent from the server to all clients
Server
Client
RemoteEvent
Game Over
Event sent from the server to a specific client
Server
Client
RemoteEvent
Display level-up UI on level-up
Event sent from the client to the server
Client
Server
RemoteEvent
Skill button click
Request sent from the client to the server, with a result returned
Client
Server
RemoteFunction
Purchase result and remaining balance
Request sent from the server to a client, with a result returned (not recommended)
Server
Client
RemoteFunction
See Important Notes below
Clients of different players cannot communicate with each other directly. To pass a value from client A to client B, it has to travel client A ➡ server ➡ client B, and the server has to validate the value along the way.
RemoteEvent and RemoteFunction Objects
RemoteEvent is an object provided to handle events between the server and client, supporting one-way communication. The sender does not stop and moves on to the next line right away.
RemoteFunction is an object provided to handle requests and responses between the server and client, supporting two-way communication. The caller yields until the result arrives. Use it when you need the response before deciding what to do next, such as a purchase result or a lookup of data the server holds.
Direction
One-way (request only)
Two-way (request and response)
Sender behavior
Keeps running without stopping
Waits until a value is returned
How to connect
OnServerEvent:Connect(function)
OnServerInvoke = function — only one can be assigned
Return value
Cannot receive one
Receives multiple values as a Tuple
Sending to many clients
FireAllClients supported
Not supported
Use RemoteEvent for notifications that need no result. A synchronous call stops the caller, so a long server-side task also delays that client’s input handling and UI.
Both objects must be accessible from both sides. To achieve this, they are placed in ReplicatedStorage, a storage where the server and client can share data. ReplicatedStorage safely synchronizes objects between the server and client, ensuring that they are accessible in both environments. If you move one into a location only one side can see, such as a server-only storage, scripts on the other side cannot reference it.

💡 Tip. To clearly distinguish whether the object 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 object’s role intuitive, enhancing code readability and maintainability.

Communication Using RemoteEvent
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.
FireAllClients (Server ➡ All Client)
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
FireClient (Server ➡ Specific Client)
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
FireServer (Client ➡ Server)
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
Communication Using RemoteFunction
A server Script assigns a callback to OnServerInvoke, and a client LocalScript calls it with the InvokeServer method. The arguments passed in the call arrive starting from the second parameter of the callback, and whatever the callback returns goes back to the client.
InvokeServer (Client ➡ Server ➡ Client)
In Script (handling side)
In LocalScript (calling side)
The first parameter of OnServerInvoke, player, is not a value sent by the client. The server determines it from the request itself, so you can rely on it for permission checks. Everything after it is sent by the client and cannot be trusted.
Callback Rules for OnServerInvoke
OnServerInvoke is not an event but a property that holds a function. It works differently from OnServerEvent, so keep these three points in mind.
You cannot use
:Connect(). Assign it asOnServerInvoke = function.Only one function is kept. If you assign more than once, only the last assigned function runs.
If you omit
return, the caller receivesnil. Using that value directly can cause an error later in the code.
Overlapping calls each run the callback separately. If you replace OnServerInvoke while a call is in progress, that call finishes with the previous function, and only new calls made afterward use the new one.
Server-Side Validation
The engine passes values sent by the client to the callback without inspecting them. Checking the type and the range is entirely up to your script. This applies equally to OnServerInvoke of a RemoteFunction and OnServerEvent of a RemoteEvent.
Check the following three steps in order.
Permission — Confirm that this
playeris entitled to make this request right now. (Distance, state, ownership, cooldown)Type and structure — Check the actual type with
typeof(). A client can send a forged table that looks like an Instance, so filter withtypeof(item) == "Instance".Value range — Check the minimum and maximum.
NaNpasses range checks because every comparison against it isfalse, andInfpasses unless you check for an upper bound.
Limit the call interval and count per player to block excessive requests.
Do not rely on client-side validation alone. Client code can be tampered with, so server-side validation is always required.
Do not accept values from the client that the server already knows. (For example, price or ownership)
Important Notes
The Call Never Resumes Without a Callback
If you call a RemoteFunction whose OnServerInvoke has not been assigned, the calling thread stops forever with no error and no timeout. There is no way to cancel the wait.
Design your initialization order so the server assigns the callback before any client call is made.
If the work can take a long time, consider sending the request with a RemoteEvent and reporting the result through a separate event when it finishes.
You can tell a hang and an error apart by the symptom. Assigning a value that is not a function (a module table, for example) passes silently, and the error appears the moment you call it. In other words, if nothing happens at all, the callback is not assigned; if an error appears right at the call, a non-function value was assigned.
Use the Correct Script Type
InvokeServer can only be called from a LocalScript, and InvokeClient only from a Script. Calling from the wrong place is not silently ignored; it raises an error.
Callback Errors Propagate to the Caller
An error raised in the server callback is delivered to the calling client and interrupts the client code. If the work can fail, wrap the call in pcall() or return a success flag instead of raising an error.
RemoteEvent has no such propagation. An error in the receiving callback does not affect the sender.
Do Not Use InvokeClient
InvokeClient, which lets the server call a client, carries three risks, so its use is strongly discouraged.
An error raised on the client propagates to the server and interrupts the server code.
If the target client disconnects during the call, an error is raised.
If the client never returns a value, the server stops forever. A malicious client can trigger this on purpose.
If the player argument is not valid, the callback does not run and an error is raised at call time. These are the four cases.
The value is
nilThe value is an Instance that is not a Player
The value is not an Instance (including a table forged to look like a Player)
The value is a reference to a Player who has already left
Be especially careful when you store a reference to a player who has left and call with it later. Check that a stored reference is still under Players before using it.
Alternative : Send the request with RemoteEvent:FireClient(), and if you need a result, have the client send it back through a separate RemoteEvent.
Values Change When Crossing the Boundary
Values that cross the server-client boundary are converted along the way. This applies equally to RemoteEvent arguments and to RemoteFunction arguments and return values, and no error or warning is raised.
Functions are not delivered. Passing one directly results in
nil, and placing one as a table value removes that key entirely. If you need to pass a callback, agree on a string name and map it on the receiving side.Instances that are not replicated, such as those under
ServerStorage, disappear the same way.Tables are delivered as copies. Filling an argument table on the receiving side leaves the sender’s original empty, so receive what you need as a return value. Metatables are not delivered.
Use string keys only. If a table holds both array elements and named fields, the named fields disappear, numeric keys turn into strings, and instances or functions used as keys can no longer be looked up with the original key.
Advanced Usage
For communication that needs no return value, use RemoteEvent instead of RemoteFunction. A synchronous call stops the caller.
Since data sent from the client cannot be trusted, it should always be validated by the server. (See Server-Side Validation above)
Send only the necessary information to the server to reduce network load. (Send only minimal data from the client)
Avoid creating too many RemoteEvents or RemoteFunctions. If tasks can be handled in the same context, process them with a single object.
Create RemoteEvent connections only when necessary, and disconnect when finished to avoid memory leaks. (
Disconnect()function)When using a single object to handle multiple tasks, add the first argument (EventType) to indicate the task type. (Example of using EventType: PlayerActionType and ActionID)
Do not perform long waits inside a callback. The calling client waits just as long.
For communication within the same environment, use BindableEvent or BindableFunction.
Last updated