--create tables:

for i,part in pairs(model:GetChildren()) do
	if (string.sub(part.Name, 1,1) == "a" or string.sub(part.Name, 1,1) == "c") and part:IsA("BasePart") then
		table.insert(a, 1, part)
	end
end
for i,part in pairs(model:GetChildren()) do
	if (string.sub(part.Name, 1,1) == "b" or string.sub(part.Name, 1,1) == "c") and part:IsA("BasePart") then
		table.insert(b, 1, part)
	end
end

function lightOn(T)
	for i, part in pairs (T) do
		part.SurfaceLight.Enabled = true
		if part:FindFirstChild("SpotLight") then 
			part.SpotLight.Enabled = true
		end
	end
end

function lightOff(T)
	for i, part in pairs (T) do
		part.SurfaceLight.Enabled = false
		if part:FindFirstChild("SpotLight") then
			part.SpotLight.Enabled = false
		end
	end
end

function run()
	while on do
		lightOn(a)
		wait(0.18)
	
		lightOff(a)
		wait(0.04)
	
		lightOn(a)
		wait(0.13)
	
		lightOff(a)
		wait(0.03)
		
		lightOn(b)
		wait(0.18)
	
		lightOff(b)
		wait(0.04)
		
		lightOn(b)
		wait(0.13)
	
		lightOff(b)
		wait(0.03)
	end
end

script.Parent.RemoteEvent.OnServerEvent:Connect(function()
	if on == true then
		on = false
	else
		on = true
		run()
	end
end)
