Client and server

Where code runs, and what travels between the two sides.

A place runs as a server with clients attached. The server loads the place, simulates the world, and sends every change to the clients. Each client renders what it receives and runs its own scripts. One place, two views.

Which script runs where

Class Runs on Typical home
Script the server ServerScriptService, Workspace
LocalScript one client StarterPlayer, StarterGui
ModuleScript whichever side requires it first ReplicatedStorage

A script can ask where it is:

local RunService = game:GetService("RunService")

if RunService:IsServer() then
    print("the server half")
else
    print("a client half")
end

What each side sees

  • The server sees the whole tree, including ServerScriptService, which clients never receive.
  • ReplicatedStorage reaches both sides: the same instances at the same paths, which is what makes it the home for shared modules and remotes.
  • StarterGui and StarterPack are templates. Each joining player gets copies in their own PlayerGui and Backpack, and the copy is what runs.
  • A client's copy belongs to that client. A change a client script makes stays on that client; the server learns nothing until a script tells it.

Crossing the gap

You want Use
a message, either direction RemoteEvent
an answer the client waits for RemoteFunction

A remote carries data, not authority. The server decides what a message means, and a client cannot change the world everyone shares except by asking.

The RemoteEvent page shows the pair of scripts that pass a message from a client to the server and back.

See also