Codectionary / Developer documentation / Luau

RemoteEvent requests and notifications

RemoteEvent sends a message without waiting for a return value. A client calls FireServer; Roblox supplies the sending Player to OnServerEvent. The server can target one client with FireClient or broadcast with FireAllClients. This example requests a fixed help message, not a reward.

Syntax

remote:FireServer("help")
-- Server listener receives (player, "help")

Examples

Validate a small request on the server

Create a RemoteEvent named LessonHelp in ReplicatedStorage. Put this Script in ServerScriptService. Only the literal help action is accepted, and each player can receive one reply per second.

local Players = game:GetService("Players")
local remote = game:GetService("ReplicatedStorage"):WaitForChild("LessonHelp")
local lastRequest = {}
remote.OnServerEvent:Connect(function(player, action)
    if typeof(action) ~= "string" or action ~= "help" then return end
    local now = os.clock()
    if now - (lastRequest[player] or -math.huge) < 1 then return end
    lastRequest[player] = now
    remote:FireClient(player, "Open the lesson panel to continue.")
end)
Players.PlayerRemoving:Connect(function(player)
    lastRequest[player] = nil
end)

Listen before sending

LocalScript in StarterPlayerScripts, paired with the RemoteEvent and server script above. Connect before FireServer so a quick reply has a listener. FireAllClients belongs on the server and should carry server-chosen messages.

local remote = game:GetService("ReplicatedStorage"):WaitForChild("LessonHelp")
remote.OnClientEvent:Connect(function(message)
    print(message)
end)
remote:FireServer("help")

Best practices

  • Never accept a client-supplied Player or reward amount as authority; OnServerEvent already identifies the sender.
  • Validate argument types, allowed values and game state before making changes.
  • Use per-player limits and remove their entries on departure; a single global debounce unfairly blocks other players.

At a glance

Purpose
Typed scripting and Roblox development
File extension
.luau
Runs in
Luau host; Roblox engine examples require Roblox Studio
Usually used with
Roblox APIs and Studio

Specifications & further reading

Related Luau documentation