Module 10 · Client and server
What runs on the server and what runs on the client
Separate authority, replication, and local presentation.
What you will learn
- Describe server authority and client presentation
- Explain why client claims are untrusted
- server
- The authoritative simulation shared by connected players.
- client
- One player's local game process and presentation.
- replication
- Roblox synchronizing supported state across the network boundary.
Loading saved progress…
Understand
Read the idea and follow a worked example.
Why this matters
A Coin Quest player should not award their own currency, but their device should control responsive local HUD effects.
The mental model
The server decides shared game truth: currency, damage, inventory, and purchases. A client handles local input, camera, and presentation.
Replication shares supported state, but a request from a client is still a claim the server must validate.
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.
print(...) calls the built-in print function. Put the values to show inside its parentheses; separate multiple values with commas. Read the result in Studio's Output panel.
local is read as “local”: it creates a name that is available only in the current code scope.
if is read as “if”: it starts a decision by evaluating a condition.
then is read as “then”: it marks the body that can run when the condition is truthy.
else is read as “else”: it provides the fallback branch.
end is read as “end”: it closes a block such as a decision, loop, or function.
: is read as “colon”: it calls a method with the object supplied as the first receiver value.
A tiny example
--!strictlocal RunService = game:GetService("RunService")if RunService:IsServer() then print("Authoritative server context")else print("Local client context")endLine by line
- 3
RunService exposes the current execution context.
- 5
IsServer asks whether this code is in server context.
- 6
The server branch names its authority.
- 8
The alternative describes client context.
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: RunService exposes the current execution context.
Line 5: IsServer asks whether this code is in server context.
Line 6: The server branch names its authority.
Line 8: The alternative describes client context.
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: Each responsibility has a reason tied to authority or presentation.
Reading or printing a value leaves it unchanged. Look for assignments, calls that change state, and property updates to explain each change you observe.
Predict before running
Which side must own a player's coin balance?
Try it
Mark each step after you have tried it.
Common mistake
A LocalScript changing a displayed number does not make that number trustworthy currency. The server must own the actual balance and replicate approved changes.
Checkpoint
Submit once you have considered every question. Retries are unlimited.
Recap
- The server owns shared authority.
- Clients handle local interaction and presentation.
- Every client claim requires server validation.
Next: Next, a client will send a small request through a RemoteEvent.
Studio Companion
Not connected
Connect once. Compatible challenges will prepare automatically as you reach them.