day night cycle roblox
local length = 12
--length is in minutes
local cycle = length*60
local minutes = 24*60
local lighting = game:GetService("Lighting")
local start = tick() - (lighting:getMinutesAfterMidnight() / minutes)*cycle
local TimeEnd = start + cycle
local Ratio = minutes / cycle
if length == 0 then
length = 1
end
repeat
local current = tick()
if current > TimeEnd then
start = TimeEnd
TimeEnd = start + cycle
end
lighting:setMinutesAfterMidnight((current - start)*Ratio)
wait(1/15)
until false