Codectionary / Developer documentation / Luau

Lighting and time of day

Change a place’s global lighting time to create day or night.

Why use Lighting?

Lighting is a service that controls global scene appearance. ClockTime is a numeric time-of-day setting, useful for a day/night cycle or a fixed mood.

Try it in Roblox Studio

Put this Script in ServerScriptService. Watch the scene in Studio after starting the server; lighting may also depend on other Lighting properties and effects.

Syntax

game:GetService("Lighting").ClockTime = 18

Examples

Lighting and time of day

Set an evening scene.

local lighting = game:GetService("Lighting")
lighting.ClockTime = 18
print("Clock time:", lighting.ClockTime)
  1. GetService returns the Lighting service rather than creating a new one.
  2. ClockTime = 18 sets the time to about 6 p.m. in the service’s 0–24 hour representation.
  3. The print confirms the value; the visible result also depends on atmosphere, sky and lighting settings.

Best practices

  • Change global lighting on the server when every player should see the same state.
  • Test visual results across graphics settings and device types.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading