Feedback on my Day/Night cycle script

Hello everyone,

I have seen a lot of day/night cycle scripts but seen none of them use tween service which is weird because I feel it’s more smooth so I decided to make it like that

local co = coroutine.resume(coroutine.create(function()
	wait(2)
	local Tick = 1 -- the time it needs to pass 1 hour in game
	while true do
		local tween = game:GetService("TweenService"):Create(game.Lighting,TweenInfo.new(Tick,Enum.EasingStyle.Linear),{ClockTime = game.Lighting.ClockTime + 1})
		tween:Play()
		tween.Completed:Wait()
	end
end))

What do you think?

1 Like

This is deoptimized. Use task.wait() instead.

You should define your services at the beginning of the script instead of just keep getting it

2 Likes

Layout and indentation, it’s sickening. Straddle this script with a fresh function.

2 Likes