Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to fade Lights? using a loop statement?

Hello,

I would like to know how I would go about fading a light on and off. I have a bunch of lights inside a model and I need them all to fade on and off when I tell it to do so in a main script. I know that I would have to use a loop.

Thanks,

Anthony

1 answer

✓ Accepted answer

To fade a Light, simply lower the Brightness gradually to 0.

You should probably use TweenService to gradually transition the Brightness to 0.

If you have a bunch of lights in a model, perhaps something like this could work:

local Model = MODEL_HERE -- Change to your model
local TweenService = game:GetService("TweenService")
 
local Goals = {
    Brightness = 0;
}
 
local Duration = TweenInfo.new(5)
 
local Descendants = Model:GetDescendants()
for a = 1, #Descendants do
    local Part = Descendants[a]
    if Part:IsA("Light") then
        TweenService:Create(Part, Duration, Goals):Play()
    end
end

I wrote this on mobile, so I apologize if I messed it up. Good luck, though!

This discussion is preserved as it was. New answers, comments, and votes are closed.