How to make nights shorter in a day/night cycle?

The title is self explanatory, i want to make it so in a day/night cycle the nights are shorter and days are longer, with days being 5 minutes and nights 1 minute.

Thanks!

Do you have a working day/night script to modify?

local dayLength = 15

local cycleTime = dayLength*60
local minutesInADay = 24*60

local lighting = game:GetService("Lighting")

local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
local endTime = startTime + cycleTime

local timeRatio = minutesInADay / cycleTime

if dayLength == 0 then
	dayLength = 1
end

repeat
	local currentTime = tick()
	
	if currentTime > endTime then
		startTime = endTime
		endTime = startTime + cycleTime
	end
	
	lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
	wait(1/15)
until false

local lighting = game:GetService("Lighting")

while task.wait() do
	if lighting.ClockTime >= 6 and lighting.ClockTime <= 18 then
		lighting.ClockTime += 0.001
	else
		lighting.ClockTime += 0.003
	end
end

Days are 3 times slower than nights here, night time appears at 6PM and finishes at around 6AM, which means the day time lasts between 6AM to 6PM.

1 Like

There has been a simular post previously, I suggest you search it up next time before making a post.

The post does not have a solution marked
I will be using this post’s script & modifying it.

local LightingService = game:GetService("Lighting")
local RunService = game:GetService("RunService")

RunService:BindToRenderStep("DayNightCycle", 1, function(dt) -- Delta time
   local ct = lighting:GetMinutesAfterMidnight() -- current time
   local i =  (ct > 18*60 or ct < 6*60) and 10 or 5 -- if the time is higher than 18:00 or lower than 6:00 then i will be 10 else i will be 5
   LightingService:SetMinutesAfterMidnight(ct + dt * i)
end)

If this answers your question please mark my post as solution.

1 Like