I want to make a script for my game that does the following:
- Gets the time in a specific timezone (e.g. GMT+10)
- Starts a loop for a day and night cycle from that.
I know how to make a day and night cycle, but am unsure how to connect the server to an irl timezone at the beginning of server start.
Please help me!
You would need to get a DateTime object which is
To set this at the local time zone
If you wanted to set a specific timezone you would need to +/- the offset to the UTC time.
There is a community tutorial here:
Timezones In Scripting - Resources / Community Tutorials - Developer Forum | Roblox
And for more information check this page
DateTime | Documentation - Roblox Creator Hub
use tick and convert it to the timezone, then set it to
local Lighting = game:GetService("Lighting")
local TimeOffset = 10
local function GetClockTime()
return ((os.date("%H") - TimeOffset)) +
(os.date("%S") / 3600) +
(os.date("%M") / 60)
Thank you for this code. However, I’m still running into issues with the cycle repeating.