Codectionary / Developer documentation / Luau

Script, LocalScript and ModuleScript placement

The same code can behave differently depending on where it runs. These lessons use server Scripts in ServerScriptService and LocalScripts in StarterPlayerScripts or StarterGui. A ModuleScript runs when required. Script RunContext also affects execution, so inspect it when a script appears silent.

Syntax

print(script.ClassName, script:GetFullName())

Examples

Identify a server entry point

Create a Script in ServerScriptService. Keep its default Legacy run context, or explicitly select Server. Press Play and inspect Output to see that it runs on the server.

local RunService = game:GetService("RunService")
print("Server:", RunService:IsServer())
print(script:GetFullName())

Identify a client entry point

Create a LocalScript in StarterPlayer > StarterPlayerScripts. During Play, Roblox copies it into that player’s PlayerScripts. LocalPlayer exists on this client, not in the server example.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
print("Client:", RunService:IsClient())
print(Players.LocalPlayer.Name)
print(script:GetFullName())

Best practices

  • When debugging, check script type, location, Enabled and RunContext before rewriting the code.
  • A ModuleScript in ReplicatedStorage is shared source, not shared mutable client/server memory.
  • A LocalScript placed directly in ReplicatedStorage does not run; use a supported client location or deliberately configured client Script.

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