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 more than 1 light at a time?

Hello,

So I am a little stuck here. I have 10 bricks within a model. In those bricks is a point light. Here is what I am using

lights = game.workspace.Model:GetChildren()
 
for i,v in pairs (lights) do
v.PointLight.Brightness = .1
wait(.1)
v.PointLight.Brightness = .2
end

I can't figure out why it is only doing one a time when I need it to do all of them at once. Is there something else I should be using.

Thanks, Antux

1 answer

✓ Accepted answer

Your problem is that you're only looking at one Part and its PointLight in the model at a time with your current for loop when you need to be changing all of their PointLights' Brightness properties to the same value at the same time. Here's how it should be done:

local lights = game.Workspace.Model:GetChildren()

-- First, you need the brightness value
-- Starts at 0.1, increments by 0.1 at a time until it reaches 1
for i = 0.1, 1, 0.1 do 
	-- Now, you change the brightness of all of them at the same time
	for _, v in ipairs(lights) do
		v.PointLight.Brightness = i
	end

	-- Waits 0.1 seconds before adding 0.1 to the brightness value
	wait(0.1) 
end

Hope this helps! if it does, don't forget to click Accept Answer and +1 my Rep!

1 comment

0

"don't forget to click Accept Answer and +1 my Rep!", Oh boy, people are becoming like me when I first started on this site 2 years ago.

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