How can I script an atmosphere to slowly fade away at random times?

I know how to change properties through script, such as game.lighting.atmosphere.density or something, but how do I script it so that it changes smoothly instead of an abrupt change? Also, is math.random good for randomizing durations between changes?

1 Like

Have you looked into TweenService? Basically, how TweenService works is it smoothly transitions one property value, for example, this is how you would create a tween and play it:

local TS = game:GetService("TweenService")
local TI = TweenInfo.new(TimeToComplete, EasingStyle, Easing Direction) -- Tween info for the tween

local Tween = TS:Create(game.Lighting.atmosphere, TI, {PropertyToChange = New Value}) -- Makes the tween for an object, and tweens the specified property
Tween:Play() -- Plays the tween
Tween.Completed:Wait() -- Waits until the tween finishes playing

If you want to, there’s nothing wrong with that.

6 Likes