Remote Events
[!Summary] RemoteEvents send one-way messages between the server and clients for events like input, state changes, or game actions. Use
FireServerfrom the client andOnServerEventon the server, or useFireClient/FireAllClientsfrom the server and handleOnClientEventon the client.
Remote Events
A RemoteEvent enables one-way communication between the server and clients. It doesn’t wait for a response and has no return value. It’s built for telling the other side what happened, not asking the other side for a result. For a call that needs a response, use RemoteFunction instead.
The primary parent container for remote events is ReplicatedStorage, as both the server and client can see and access it.
⚠ Security note: never trust arguments a client sends via
FireServerat face value - a modified client can call it with anything. Re-validate any arguments on the server before acting on them.
Example
In this example, pressing E changes a part named ColorBlock to a random color. Key presses can only be detected on the client, but the color change needs to happen on the server so every player sees the same result, which is what the remote event is for.
Server Script
- placed in
ServerScriptService - Be sure to create an event named
ChangeColorparented toReplicatedStorage
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local changeColor = ReplicatedStorage.ChangeColorlocal colorBlock = workspace.ColorBlock
changeColor.OnServerEvent:Connect(function(player) colorBlock.Color = Color3.fromRGB(math.random(0, 255), math.random(0, 255), math.random(0, 255))end)Client Script
- placed in
StarterPlayerScripts
local ReplicatedStorage = game:GetService("ReplicatedStorage")local UserInputService = game:GetService("UserInputService")
local changeColor = ReplicatedStorage.ChangeColor
UserInputService.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then changeColor:FireServer() endend)Methods
| Method | Returns | Description |
|---|---|---|
FireServer(...) | void | Called from a client. Sends arguments to the server. |
FireClient(...) | void | Called from the server. Sends arguments to the chosen client. |
FireAllClients(...) | void | Called from the server. Sends arguments to every client. |
Events
| Event | Parameters | Description |
|---|---|---|
OnServerEvent | player, … | Fires on the server when a client calls FireServer. |
OnClientEvent | … | Fires on the client when the server calls FireClient or FireAllClients |
Vortex Studio 0.3.4 notes
- Create RemoteEvents in
ReplicatedStoragethrough the editor before play. Editor-authored remotes dispatch fromFireServertoOnServerEvent; script-created remotes were visible to clients but did not dispatch in the tested runtime. - The first
OnServerEventvalue is currently a numeric connection ID, not aPlayer. The server can enumerate Players throughGetPlayers(), but no public mapping from this ID to the corresponding Player, Character, or Humanoid is known. - Remote arguments cannot currently contain Instances, including
LocalPlayeror a Character. FireClient,FireAllClients, andOnClientEventare exposed, but their delivery remains unconfirmed.