Help with flashing and color changing lights

https://gyazo.com/eba9fc678d983d06f6c179ff9f6d1e48

I think i have an idea on how to do it but not sure.

so what i want to do is when the red button is press all the lights in the group will turn red and flash and then after 45 second it will go back to normal

Make a function that gets all the children of the group, checks if they’re a pointlight, if they are then it changes the pointlight’s color to the function’s parameter.

Then just do something like
runFunction(Red) wait(45) runFunction(white)

im a bit confused this is the script i have

while true do

script.Parent.PointLight.Color = 255, 0, 0
script.Parent.PointLight.Enabled = true
wait(0.5)
script.Parent.PointLight.Enabled = false
wait(0.5)

while false do

			script.Parent.PointLight.Color = 255, 255, 255			
		end
	end

what do i need to do to make it run when the brick is clicked

Please read this documentation on the ClickDetector class before asking questions such as that. A lot of questions can be answered by a singular google search.

Good luck :slight_smile:

local ClickDetector = script.Parent.ClickDetector
local Light = game.Workspace.LightPart.PointLight

ClickDetector.MouseClick:Connect(function()
while true do

	script.Parent.PointLight.Color = 255, 0, 0
	script.Parent.PointLight.Enabled = true
	wait(0.5)
	script.Parent.PointLight.Enabled = false
	wait(0.5)

	while false do	

		script.Parent.PointLight.Color = 255, 255, 255
	end
end)

end)

am i heading on the right track

Yeah! I’d recommend formatting your script better though.

local Lights = workspace.Lights:GetDescendants()
local ClickDetector = script.Parent


local Buf = {}
for ObjIndex = 1, #Lights do
	if Lights[ObjIndex]:IsA("Light") then
		table.insert(Buf, {Lights[ObjIndex], Lights[ObjIndex].Color})
	end
end
Lights = Buf
Buf = nil


local Running = false
ClickDetector.MouseClick:Connect(function()
	if Running then return end
	Running = true
	for LightIndex = 1, #Lights do
		Lights[LightIndex][1].Color = Color3.fromRGB(255, 0, 0)
	end
	for i = 1, 90 do
		for LightIndex = 1, #Lights do
			Lights[LightIndex][1].Enabled = true
		end
		wait(.25)
		for LightIndex = 1, #Lights do
			Lights[LightIndex][1].Enabled = false
		end
		wait(.25)
	end
	for LightIndex = 1, #Lights do
		Lights[LightIndex][1].Color = Lights[LightIndex][2]
	end
	Running = false
end)

Lights.rbxl (22.9 KB)