Day/Night Cycle Speed

I have the script made, but the times are messed up and I can’t figure it out. I want it to day and night last about 8 minutes each. Here is my Script:

local Time = 10
local TimeChange = 10


while wait(Time) do
	game.Lighting.ClockTime = game.Lighting.ClockTime + TimeChange
end

Each whole number of ClockTime is an hour. You are adding 10 hours each pass.

Try:

local Time = 10
local MinutesInADay = 8

while wait(Time) do
	game.Lighting.ClockTime = game.Lighting.ClockTime + Time / (MinutesInADay * 60) * 24
end

https://developer.roblox.com/en-us/api-reference/property/Lighting/ClockTime

2 Likes

Now I have to wait 8 minutes to see haha.

You can use TweenService for a smoother approach:

local CycleTime = 8 -- how long you want the cycle to last
local TweenService = game:GetService("TweenService")

while true do
local tween = TweenService:Create(game.Lighting, TweenInfo.new(CycleTime * 60), {ClockTime = 24}) 
tween:Play()
tween.Completed:Wait()
game.Lighting.ClockTime = 24
end

Note: Im pretty sure the midnight ClockTime is 24, if its not lmk.

1 Like