Multiplayer, saving and debugging, lesson 26
Client and server
Goal: Know which side a script runs on, and which side to trust.
about 6 min3 practice exercises
A Roblox game runs in several places at once. The server is a computer run by Roblox that holds the true state of the game. Each player's device is a client. It shows the game to that player and sends their input.
Client: a player's device
Another client
Server: run by Roblox
Which side a script runs on depends on its type and where you put it:
| Script | Runs on | Typical home |
|---|---|---|
| Script | The server | ServerScriptService |
| LocalScript | One player's client | StarterPlayerScripts, StarterGui |
| ModuleScript | Whoever requires it | ReplicatedStorage (shared), ServerScriptService (server only) |
The two sides see different things:
- Things in ReplicatedStorage are copied to every client. Put shared items there.
- ServerScriptService and ServerStorage are for the server. Keep anything players must not read or change there.
The most important fact in multiplayer scripting: a change made on a client stays on that client. If a LocalScript sets a player's coins to 1,000,000, only that player sees it. The server, and everyone else, still has the real number.
So the rule is simple. Anything that matters (coins, damage, purchases, who won) is decided on the server. The client's job is input, camera, UI and effects.
Sources
Checked against Roblox's documentation on . The lesson is in our own words; these pages are the source of truth.