Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to fade Lights? using a loop statement?

Asked by 6 years ago

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

Log in to vote
0
Answered by
Validark 1580 Snack Break Moderation Voter
6 years ago
Edited 6 years ago

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!

Ad

Answer this question