For i,v not moving on after wait

My code:

PlacePrompt.Triggered:Connect(function()
	if TNTHeld.Value == true then
		print("Placing TNT")
		--false is sent to request clients to close gui
		UIRemote:FireAllClients(false)
		local TNTPCFrame = PH.CFrame.Position
		TNT.CFrame = CFrame.new(TNTPCFrame)
		PH.Transparency = 1
		TNT.Transparency = 0
		
		wait(5)
		
		local explosion = Instance.new("Explosion")
		explosion.BlastPressure = 10000000
		explosion.BlastRadius = 30
		explosion.Position = Vector3.new(-185.713, 6.77, 586.069)
		explosion.Parent = game.Workspace
		
		Debris:AddItem(TNT, 0.01)
		
		local parts = game:GetService("Workspace").WIP_Map.Wall.WallBoom:GetChildren()
		
		print("Action 1")
		for i,v in pairs(parts) do
			Instance.new("Fire", v)
		end
		
		wait(1)
		
		print("Action 2")
		for i,v in pairs(parts) do
			v.Color = Color3.new(0.168627, 0.168627, 0.168627)
		end

	else
		print("I need TNT to place")
	end
end)

My issue:
So we been trying to debug this issue for a while, but basically on the for i,v loops action 1 completes, however once it completes it will not go on to action 2. We tried removing the wait and thats what does it, however we kind of need the wait. Any suggestions?

for i,v in pairs(parts) do
Instance.new("Fire", v)
print"working"
end

Try adding this and see if it just keeps printing “Working”

Also maybe switch from wait to task.wait as that’s good practice now.

It doesn’t keep printing. ahhhhhhh

So does print("Action 2") never get reached? Like does Action 2 show up in the output?

Odd behavior if so cause it should print unless something ends it early.

Task.wait fixed this issue LOL thank you so much

1 Like

Glad to hear it, make sure to switch every wait to task.wait as well.