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
Server authority, validation and rate limits
A valid-looking remote call can still be an impossible game action. Validate both the shape of a request and whether the sender may perform it now. This example lets a nearby living player request a visual switch; it does not trust a client position, target Instance or reward.RemoteFunction and yielding requests
RemoteFunction is a request/response operation: InvokeServer yields until the server returns. Use it for a small, bounded query when the caller needs a result. Avoid making essential server progress depend on invoking an untrusted client.Client/server boundaries and project structure
A server owns shared game decisions while each client handles its own input, camera and presentation. Treat client messages as requests. Put private rules in server containers and expose only the data and operations the client actually needs.Luau and Roblox scripting
Start with Luau values and functions, then use Roblox Studio to connect that code to players, Instances and events. Luau is the language; Roblox supplies the game engine APIs. Codectionary supports editing and highlighting, while these Roblox examples run in Studio.
A valid-looking remote call can still be an impossible game action. Validate both the shape of a request and whether the sender may perform it now. This example lets a nearby living player request a visual switch; it does not trust a client position, target Instance or reward.RemoteFunction and yielding requests
RemoteFunction is a request/response operation: InvokeServer yields until the server returns. Use it for a small, bounded query when the caller needs a result. Avoid making essential server progress depend on invoking an untrusted client.Client/server boundaries and project structure
A server owns shared game decisions while each client handles its own input, camera and presentation. Treat client messages as requests. Put private rules in server containers and expose only the data and operations the client actually needs.Luau and Roblox scripting
Start with Luau values and functions, then use Roblox Studio to connect that code to players, Instances and events. Luau is the language; Roblox supplies the game engine APIs. Codectionary supports editing and highlighting, while these Roblox examples run in Studio.