Why next code runs in same time with for loop and not after it

Topic explains everything. For some reason next code after loop run in same time with for loop

code:

tween.Completed:Connect(function()
			building.Effects.Smoke.Enabled = false
			cc.CFrame = bc2.CFrame
			for _,beamRacks in pairs(building.Union.Photons:GetChildren()) do
				for _,beamRack in pairs(beamRacks:GetDescendants()) do
				if beamRack:IsA("Beam") then
					local thread = coroutine.create(function(object, time, action)
						transparent(object, time, action)
					end)
					
					coroutine.resume(thread, beamRack, 2, "decrease")
				end
				end
			end
			transparent(building.Union.BeamConnectMain.Beam, 2, "decrease")
		end)
1 Like

Because the loops in are wrapped in a coroutine which doesn’t yield.

Well i can’t do this without coroutine then what i should do

You could just add a task.wait(2)

before this

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.