How to make an advanced day and night cycle

Im new in scripting and I run into this problem while coding a day and night cycle

  1. What do you want to achieve?
    I want to change some lighting properties in each time of a day

  2. What is the issue? The lighting properties wont change but the day and night cycle still run normally

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes I have but none of it seems to reach my satisfaction.

local lighting = game:GetService("Lighting")

local minutes = 8 * 60
local blur = game.Lighting.Blur


while wait() do
	lighting:SetMinutesAfterMidnight(minutes)
	minutes = lighting:GetMinutesAfterMidnight()

	if minutes > 18 * 60 then
		minutes = minutes + 0.033333333333333333333
		blur = 100
	elseif minutes > 6 * 60 then
		minutes = minutes + 0.033333333333333333333
	elseif minutes > 17.8 * 60 then
		minutes = minutes + 0.02
		blur = 10
	
	end			
end

My code is here, looks really simple because Im new in scripting.
Take an example that I want to make the night a bit blur after 18 pm and I code in those blur lines up there

local blur = game.Lighting.Blur
blur = 100

but it wont run and also

elseif minutes > 17.8 * 60 then
		minutes = minutes + 0.02
		blur = 10

this small line of codes I want to make it the sunset but it didnt run
Can anyone help me solve these problems, I will be much appreciated! and does putting tween service in a day and night cycle script a good idea?

You should check out this post by a talented scripter.
If you don’t want to read the entire post, you can just copy the script at the bottom of the original post.

1 Like

The post contents so much useful information thanks you so much!