Hello, I have recently just made this script knowingly it won't work ._. What I want it to do is play a couple of sounds then I want the power to go off (spot lights) Please can someone tell me what I have done wrong!

Thanks!

BoolValue = script.Parent.Parent.EmergencyLight1.Toggle
BoolValue2 = script.Parent.Parent.EmergencyLight2.Toggle
Meltdown1=game.Workspace.Meltdown1
Meltdown2=game.Workspace.Meltdown2
Meltdown3=game.Workspace.Meltdown3
Meltdown4=game.Workspace.Meltdown4 
 
function onClick()
    if BoolValue.Value == false then
        BoolValue.Value = true
        BoolValue2.Value = true
        print(BoolValue.Value)
    Meltdown1:Play()
wait(3)
Meltdown2:Play()
wait(5)
Meltdown3:Play()
wait(10)
Meltdown4:Play()
wait(50)
Meltdown3:Stop()
    else BoolValue.Value = false
    end
end
local tab = {}
on = true
function GetAllDL(ta, p)
	for _, d in pairs(p:GetChildren()) do
		if d:IsA("SpotLight") or d:IsA("PointLight") then
			table.insert(ta,d)
		elseif d:IsA("BasePart") or d:IsA("Model") then
			GetAllDL(ta,d)
		end
	end
end
ting = 0
function on_off()
	if ting == 0 then
		ting = 1
		if on == true then
			tab = {}
			wait()
			for i=1,.5,-.1 do
				script.Parent.Mesh.Scale=  Vector3.new(1,i,1)
				wait()
			end
			GetAllDL(tab,Workspace)
			wait(2)
			for _, g in pairs(tab) do
				if g ~= nil then
					g.Enabled = false
				end
				wait()
			end
			on = false
			script.Parent.BrickColor = BrickColor.new("Really red")
			wait(5)
			for i=.5,1,.1 do
				script.Parent.Mesh.Scale =  Vector3.new(1,i,1)
				wait(.25)
			end
			ting = 0

		elseif on == false then
			for i=1,.5,-.1 do
				script.Parent.Mesh.Scale=  Vector3.new(1,i,1)
				wait()
			end
			for _, g in pairs(tab) do
				if g ~= nil then
					g.Enabled = true
				end
				wait()
			end
			on=true
			script.Parent.BrickColor = BrickColor.new("Lime green")
			wait(5)
			for i=.5,1,.1 do
				script.Parent.Mesh.Scale=  Vector3.new(1,i,1)
				wait(.25)
			end
			ting = 0
		end

	end
end
script.Parent.ClickDetector.MouseClick:connect(on_off)


BoolValue = script.Parent.Parent.EmergencyLight1.Toggle
BoolValue2 = script.Parent.Parent.EmergencyLight2.Toggle
Meltdown1=game.Workspace.Meltdown1
Meltdown2=game.Workspace.Meltdown2
Meltdown3=game.Workspace.Meltdown3
Meltdown4=game.Workspace.Meltdown4 
 
function onClick()
    if BoolValue.Value == false then
        BoolValue.Value = true
        BoolValue2.Value = true
        print(BoolValue.Value)
    Meltdown1:Play()
wait(3)
Meltdown2:Play()
wait(5)
Meltdown3:Play()
wait(10)
Meltdown4:Play()
wait(50)
Meltdown3:Stop()
    else BoolValue.Value = false
    end
end

This bit works fine but the other code below doesn't. And also the code below works fine without the top bit.