Weird light flickering when using my day/night cycle

Hello everyone,

I’m making a day/night cycle system and stumbled upon a rather annoying problem,

here is the problem basically:

as you can see the light flickers weirdly and I’m not sure why.

Here is the script:

local TweenService = game:GetService("TweenService")
local Tick = 1 -- the time it needs to pass 1 hour in game
local Info = TweenInfo.new(Tick,Enum.EasingStyle.Linear)
local Time = game.Lighting


game.Lighting:GetPropertyChangedSignal("ClockTime"):Connect(function(change)
	local Time = game.Lighting.ClockTime
	if Time == 18 then
		
	end
	if Time == 6 then

	end
end)


while true do
	local tween = TweenService:Create(Time,Info,{ClockTime = Time.ClockTime + 1})
	tween:Play()
	tween.Completed:Wait()
end

Any help?

That script is not the cause, probably theres another script that is changing any other Lighting property?
Test that script alone in a different place, theres no flickering

You are right however there is no other script the changes anything about lighting so idk

Maybe a bug in studio? It has the same issue on a roblox server?
Try a different approach for the system. Remove the while loop creating and playing a tween, and use RunService renderstep to update the lighting clock. Could help to debug

It turned out the Clouds instance was covering the sun rays :sweat:
Thanks for the help anyways

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.