Class
RunService
NotCreatableServiceNotReplicated
Service responsible for all runtime activity and progression of time.
RunService contains methods and events for time management as well as for
managing the context in which an experience or script is running. Methods like
IsClient(),
IsServer(), and
IsStudio() can help you determine under what
context code is running. These methods are useful for
ModuleScripts that may be required by both client and
server scripts. Furthermore, IsStudio() can be
used to add special behaviors for in‑Studio testing.
RunService also houses events that allow your code to adhere to the engine's
frame‑by‑frame loop, such as PreRender,
PreAnimation,
PreSimulation,
PostSimulation, and
Heartbeat. Selecting the proper event to use for
any case is important, so you should read
Task Scheduler
to make an informed decision.
Context Test Results#
| Environment | Class.RunService:IsStudio()|IsStudio |
Class.RunService:IsClient()|IsClient |
Class.RunService:IsServer()|IsServer |
Class.RunService:IsEdit()|IsEdit |
Class.RunService:IsRunning()|IsRunning |
Class.RunService:IsRunMode()|IsRunMode |
|---|---|---|---|---|---|---|
| Live (Client) | false |
true |
false |
true |
false |
|
| Live (Server) | false |
false |
true |
true |
false |
|
| Edit | true |
true |
true |
true |
false |
false |
| Collaborative Edit | true |
true |
false |
true |
false |
false |
| Run Mode | true |
false |
true |
true |
true |
|
| Play Mode (Client) | true |
true |
false |
true |
false |
|
| Play Mode (Server) | true |
false |
true |
true |
false |
|
| Team Test (Client) | true |
true |
false |
true |
false |
|
| Team Test (Server) | true |
false |
true |
true |
false |
|
| Luau Execution | false |
false |
true |
false |
false |