I want to make Real Daylight Cycle for my timezone Cet.
Its my code for my daylight time:
local minutesAfterMidnight = 0
while true do
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
minutesAfterMidnight = minutesAfterMidnight + 1
wait(0.1)
end
I cant look good tutorials and posts at devforum. Please help me!.
1 Like
When you make a post that includes code try and use the code format as it makes it easier for the person helping to read.
daylight time: local minutesAfterMidnight = 0
while true do
game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
minutesAfterMidnight = minutesAfterMidnight + 1
wait(0.1)
end
1 Like
Are you trying to make a system where the Day/night system where the time of day is dependent on the User’s timezone or just following a specific timezone? Either ways, both may require the use of os.date
1 Like
i want to create daylight for my timezone(CET)
ok, I was fixd thanks you for change
1 Like
For make this thing, You need to know about os at scripting.
Like: os.date or os.clock.
This will help you about os service:
1 Like
I know that but I don’t know what to make real daylight cycle
You’d have to use os.date
, passing in "!*t"
to get UTC time, and add 1 to the hours since CET is UTC+1. Then get the current minutes with some math and use SetMinutesAfterMidnight. I think something like on the server should work
local lighting = game:GetService("Lighting")
local currentTime = os.date("!*t", os.time())
local hours = currentTime.hour + 1
local minutes = currentTime.min
local seconds = currentTime.sec
while true do
local toSet = (hours * 60) + minutes + (seconds / 60)
lighting:SetMinutesAfterMidnight(toSet)
seconds += 1
if seconds == 60 then seconds = 0; minutes += 1 end
if minutes == 60 then minutes = 0; hours += 1 end
if hours == 25 then hours = 0 end
wait(1)
end
this works, but the hour is about 1 hour earlier it comes
Because right now we’re i nthe CEST timezone, we’re 1 hour forward, it would be a bit complicated to set it up so it adds 1 hour or 2 hours depending on the month and day, so I think it’s best you choose one or the other
Ok. Ty for help! I have good script!
1 Like
Anytime! If you have anymore issues don’t be afraid to make another post!