LightingTime v2.0 is an upgraded version of LightingTime version 1.0. It can be used to coordinate the day-night cycle with other in-game features, for example clocks. LightingTime v2.0 has functions that make it easier to use different time formats, set custom day lengths, and synchronize with real-world timezones — all while automatically keeping the in-game lighting updated smoothly and accurately, even if the game experiences lag.
Whats new in v2.0
- Custom day lengths – You now control how long a full day cycle takes in real-world seconds (
SetLengthOfDay). - Smooth updates using
os.clock– Instead of fixed interval updates, time now progresses based on frame-accurate delta, which handles lag spikes better. - Simplified API – Removed the need for
SetTimeSpeedandSetLightingUpdateFrequency, making it more intuitive. - Lag-resilient – Continuous updates instead of waiting set intervals reduces drift in game time.
- Core features retained – All formatting and timezone utilities are still available.
Link to model: https://create.roblox.com/store/asset/99106421166396/LightingTime-v2
Link to v1.0: https://devforum.roblox.com/t/lightingtime-v10/3768766
Documentation:
The model needs to be required using
LightingTime = require(game.ServerScriptService.LightingTime)
if it is stored in ServerScriptService
Default values:
local TimeOfDay = 14.5 * 3600 -- 2:30 PM
local LengthOfDay = 86400 -- 1 day IRL
Functions:
function LightingTime.SetLengthOfDay(seconds: number)
Sets the length of one in-game day in real seconds. Inputting 0 will result in not changing TimeOfDay automatically.
Returns: nil
function LightingTime.SetTimeOfDay(hour: number, min: number, sec: number)
Sets the current in-game time of day.
Returns: nil
function LightingTime.SetTimeFromTimezone(timezone: number)
Sets the in-game time to match real-world time at the given timezone (UTC offset).
Returns: nil
function LightingTime.GetLengthOfDay()
Returns the length of one in-game day in real seconds.
Returns: number
function LightingTime.GetTimeInSeconds()
Returns the current in-game time of day in seconds.
Returns: number
function LightingTime.GetTimeInHours()
Returns the current in-game time of day in hours (fractional).
Returns: number
function LightingTime.GetTimeInMinutes()
Returns the current in-game time of day in minutes (fractional).
Returns: number
function LightingTime.GetHour()
Returns the current hour (integer 0–23).
Returns: number
function LightingTime.GetMinute()
Returns the current minute (integer 0–59).
Returns: number
function LightingTime.GetSecond()
Returns the current second (integer 0–59).
Returns: number
function LightingTime.GetFormattedTime(format: string)
Returns the current time formatted as a string.
Formats:
"hm" returns "HH:MM"
"hms" returns "HH:MM:SS"
Returns: string or nil if format is invalid
function LightingTime.GetTimeFromTimezone(timezone: number)
Returns the real-world time in seconds for the specified timezone (UTC offset).
Returns: number
Thanks for reading this post! If you have any questions or comments, then feel free to tell me.