Module 10 · Client and server
Sending a request with RemoteEvent
Let the client ask while the server remains responsible for deciding.
What you will learn
- Send a small RemoteEvent request
- Receive it with the server-supplied Player parameter
- RemoteEvent
- A Roblox object for one-way messages across the client-server boundary.
- payload
- The explicit data sent with a network request.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
A Coin Quest client can ask to interact with a door, but the server needs to decide whether that request is allowed.
The mental model
FireServer sends a request from one client. OnServerEvent supplies the authenticated Player automatically before the client payload.
Keep payloads small and meaningful. Never let the client choose identity or final reward.
New words and symbols
--!strict asks Studio to check your code for type mistakes. It is an instruction for the editor and produces no Output message.
Matching quotes such as "hello" surround a string: a piece of text. The quotation marks tell Luau where the text starts and ends.
local is read as “local”: it creates a name that is available only in the current code scope.
: is read as “colon”: it calls a method with the object supplied as the first receiver value.
= is read as “is assigned”: it evaluates the right side and stores that value in the name on the left.
. is read as “dot”: it accesses a named property or table field.
A tiny example
--!strictlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local requestDoor = ReplicatedStorage.Remotes.RequestDoorassert(requestDoor:IsA("RemoteEvent"), "RequestDoor must be a RemoteEvent")requestDoor:FireServer("WoodenDoor")Line by line
- 3
The client accesses shared ReplicatedStorage.
- 4
The RemoteEvent is selected from a reviewed path.
- 5
The class is checked before use.
- 7
FireServer sends one small door identifier, not a reward decision.
Read the code aloud
Read one statement at a time: name the value being read, what the operation does, and where its result goes. Keep identifiers exactly as written so you can find them again in the code.
Pause at calls, conditions, and loops. Explain when the body runs before moving to the next statement; use the line notes above when a symbol is unfamiliar.
Execution trace
Begin at the first executable statement. Comments and blank lines do not run; a branch chooses which block runs, and a loop may revisit its body.
Line 3: The client accesses shared ReplicatedStorage.
Line 4: The RemoteEvent is selected from a reviewed path.
Line 5: The class is checked before use.
Line 7: FireServer sends one small door identifier, not a reward decision.
State before and after
Before running, identify the starting values and any existing Studio objects this example needs. List what you expect to change.
After your practice change, check this result: The request contains only the intended small payload and the server gets identity from Roblox.
Reading or printing a value leaves it unchanged. Look for assignments, calls that change state, and property updates to explain each change you observe.
Server receiver
--!strictlocal ReplicatedStorage = game:GetService("ReplicatedStorage")local requestDoor = ReplicatedStorage.Remotes.RequestDoorassert(requestDoor:IsA("RemoteEvent"), "RequestDoor must be a RemoteEvent")requestDoor.OnServerEvent:Connect(function(player: Player, doorId: unknown) print(player.Name, doorId)end)Predict before running
Who supplies the Player argument to OnServerEvent?
Try it
Mark each step after you have tried it.
Common mistake
requestDoor:FireServer(player, 1000)The client must not supply its identity or final reward. Roblox supplies Player, and the server calculates consequential values.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- RemoteEvents carry one-way requests.
- Roblox supplies server-side Player identity.
- A request asks; it does not decide.
Next: Next, you will validate every meaningful part of that request.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.