Coroutine won't change Particle Emitters properties or throw error [HELP!]

I have a coroutine that I’m using to Instance a new Particle Emitter and SpotLight every few seconds, then delete them.

The problem I’m having is that the script won’t edit any of the properties for the particle emitter and doesn’t even pass that part.of the script.

It doesn’t even throw an error so I have no clue what the issue is.

Here is the piece of script:


local function Lights()

	print("Lights!")
	while true do
		if Config.Progress.Value < 100 then
			
			local bulbs = Generator.lamp.bulbs print("25")
			local CurrentBulbs = bulbs:GetChildren() print("26")
			local RandomBulb = CurrentBulbs[math.random(1,#CurrentBulbs)] print("27")
			
			local ParticleEmitter = Instance.new("ParticleEmitter",RandomBulb)print("28 29")
			ParticleEmitter.LightEmission = 999999 print("30")
			ParticleEmitter = 5
			ParticleEmitter.Transparency = .5
			ParticleEmitter.Lifetime = .25
			ParticleEmitter.Rate = 5
			
			local Spotlight = Instance.new("SpotLight",RandomBulb)
			Spotlight.Angle = 40
			Spotlight.Brightness = 75
			Spotlight.Range = 40
			
			print("Boom")
			
			wait(math.random(1,2.5))
			
			print("Boom Removed")
			
			ParticleEmitter:Destroy()
			Spotlight:Destroy()
			
		end
	end	
	
end

print("Running Light Services")

local LetThereBeLight = coroutine.create(Lights)
coroutine.resume(LetThereBeLight)

Here is the output: (No Errors)


  20:26:10.847  Running Light Services  -  Server - GeneratorMain:55
  20:26:10.848  Lights!  -  Server - GeneratorMain:21
  20:26:10.849  25  -  Server - GeneratorMain:25
  20:26:10.851  26  -  Server - GeneratorMain:26
  20:26:10.851  27  -  Server - GeneratorMain:27
  20:26:10.852  28 29  -  Server - GeneratorMain:29
  20:26:10.853  30  -  Server - GeneratorMain:30

the 25 - 30 you see in the output window is just the line thats running print(line number).
I was doing this just to see if it was running the lines. It is, it’s just not editing the properties.

Thank’s for the help in advance.

You could try using the debugger to step through the code and see what the variables are and how they change.