Need help with a for loop

alright can you add print(l.Enabled) after “l.Enabled = false”?
if it says false, the script is working fine.

Does this script work for you?

1 Like

Yes, i created my own simpler version and it works just fine.

repStore.SpellEvents.FlameRitual.OnServerEvent:Connect(function()
	if game.Workspace.Altar.IsActive.Value == true then
		for _,l in pairs(game.Workspace.Flames:GetChildren()) do
			if l:IsA("ParticleEmitter") or l:IsA("SurfaceLight") then
				l.Enabled = true	
			end
		end
	end
end)

this should enable the lights and partcles

a problem is

it waits 5 seconds in between disabling each thing

so in my script i enable them and disable them 5 seconds later

it waits 5 seconds then disables one thing, another 5 disables the second and another 5 and then disables the light

yes you shouldn’t put wait inbetween the iteration
maybe create a new script iterate through all objecty you want
this time use

l.GetPropertyChangedSignal("Enabled"):Connect(function()
if l.Enabled==false then return end
  task.wait(5)
  l.Enabled=false
end)

something like this…