Scripting Help: Lightining System

Hello Developers! :tongue:

I believe you may be familiar with QSERF, given its prominence in the Sci-Fi gaming genre.

I’m currently creating a core game with some friends, and we are working on the lighting system.

In QSERF, during the DMR startup, the lights are turned off in a sort of random order, and a sound is played to accompany the shutdown. (A video will be provided)

I’ve been trying to find a solution for this randomization, shutdown, and sound for a few days now, but I haven’t been able to figure it out. =(

OFF FUNCTION:

module.Off = function()
	sound:FindFirstChild("outage"):Play()
	wait(1.6)
	sound:FindFirstChild("flicker"):Play()

	for _, v in pairs(workspace.FLights.F1:GetDescendants()) do
		if v:IsA("SpotLight") or v:IsA("PointLight") then
			v.Enabled = true
			v.Parent.Material = Enum.Material.Neon
		end
	end

	local function off(group)
		local lights = {}

		for _, v in pairs(group:GetDescendants()) do
			if v:IsA("SpotLight") or v:IsA("PointLight") then
				table.insert(lights, v)
			end
		end

		local numToAffect = math.random(2, math.min(#lights, 5))

		for i = 1, numToAffect do
			local index = math.random(1, #lights)
			local light = table.remove(lights, index)

			Generic[light] = light.Brightness
			GenericStat[light] = light.Enabled

			light.Parent.Material = Enum.Material.SmoothPlastic
			light.Enabled = false

			TweenService:Create(light, TweenInfo.new(1), {Brightness = 0}):Play()
		end
	end

	off(workspace.FLights.G1)
	off(workspace.FLights.B1)
	off(workspace.FLights.Lights)
end

Because of this, I’ve turned to the DevForum for help, as it’s my last resort to make this script work.

I hope someone can assist me, and I thank everyone in advance!

Here’s the video of QSERF’s lighting system: