How would I fade fog in and out?

I’ve got a script that changes the night and day, I’ve managed to get it to activate all lights at night (thanks to you guys <3 ).

Now I’ve added a line of code to create a dark fog at night to make it feel darker but I haven’t been able to work out how to fade the fog. It just changes abruptly.

Any help would be appreciated! :slight_smile:

4 Likes

You can use TweenService to do so.

local TweenService = game:GetService('TweenService')

local tweenInfo = TweenInfo.new(
	2, -- Time
	Enum.EasingStyle.Linear, -- EasingStyle
	Enum.EasingDirection.Out -- EasingDirection
)
 
local tween = TweenService:Create(game.Lighting, tweenInfo, {FogEnd = 100})
 
tween:Play()
7 Likes

Animating the fog coming in and out like that might look strange. If you think so, you could try adding fog with particles to disguise some of the transition and do away with it (or not) once the lighting fog is set how you like.

It won’t look strange if it’s done gradually rather than quickly. You won’t even notice :slight_smile:

1 Like