Well there are many things wrong with your code. Let's start off with the loop, which has a few problems.
while wait() do
TweenAffect:Play()
TweenAffect.Completed:wait()
wait(0.1)
end
There's no need to do while wait() do at all really it's bad practice you should always just do
while true do
wait()
But it's even worse in this case as you're already using a wait in the code, so there's no need to use two. Also tween has a parameter that allows them to loop by themselves and also a delay time parameter.
local Info = TweenInfo.new(
5,
Enum.EasingStyle.Cubic,
Enum.EasingDirection.Out,
0,
false,
0
)
That's all good and all, but the real reason your code isn't working is because of this line
local TweenAffect = TweenService:Create(game.Lighting, Info, {ClockTime = game.Lighting.ClockTime+12})
It's not going to work how you think it will. Let me explain, this variable will not update (even if it did the tween doesn't update either), so your tween will constantly just be tweening to the same value. Say it was 14:00 at the time the code ran, it would keep tweening to 02:00. You need to create a new tween every loop. So moving your code into the while loop block so it updates would look something like this.
local Info = TweenInfo.new(
5,
Enum.EasingStyle.Cubic,
Enum.EasingDirection.Out,
0,
false,
0
)
while true do
local TweenAffect = TweenService:Create(game.Lighting, Info, {ClockTime = game.Lighting.ClockTime+12})
TweenAffect:Play()
TweenAffect.Completed:Wait()
wait(0.1)
end
5 comments
Does it tween atleast once?
so you want the tween to be infinite?
Almost sure you can do that just with tween info
nope
Instead, make a function that creates and runs the tween, then make a loop that constantly loops the function.