a380man1
(a380man1)
May 28, 2023, 5:47am
#1
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!
1 Like
Wigglyaa
(Wigglyaa)
May 28, 2023, 6:48am
#2
You would need to get a DateTime object which is DateTime.now()
To set this at the local time zone DateTime.now():ToLocalTime()
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 Lighting.ClockTime
local Lighting = game:GetService("Lighting")
local TimeOffset = 10
local function GetClockTime()
return ((os.date("%H") - TimeOffset)) +
(os.date("%S") / 3600) +
(os.date("%M") / 60)
end
print(GetClockTime())
a380man1
(a380man1)
June 2, 2023, 11:14am
#4
Thank you for this code. However, Iām still running into issues with the cycle repeating.