Loop stops working after 1 run

Whenever I run the following code, I only get the “Working” print once, sometimes twice, even though from my understanding of the code it should run over and over again every second. After doing some print testing, I found out that the code stops printing anything after the first for loop. I’ve never run into this problem before

local currentLocation = nil
local wasFound = false

while true do
	for currentPart, section in pairs(workspace.locationChangers:GetChildren()) do
		local pos1, pos2 = (section.Position - section.Size / 2), (section.Position + section.Size / 2)
		local region = Region3.new(pos1, pos2)
		local playersFound = game.Workspace:FindPartsInRegion3(region)
		for i, playersInArea in pairs(playersFound) do
			if playersInArea:FindFirstAncestor(char) then
				if currentLocation ~= currentPart.placeName.Value then
					--Change the Location--
					currentLocation = currentPart.placeName.Value
					wasFound = true
					print("working")--(section.placeName.Value, section.placeOST.Value, section.placeAmbience.Value, section.placeDescription.Value)
		--They weren't found--
		if wasFound == false then
			print("working")--("The Voidzone", nil, game.SoundService.voidzone, "A place beyond the 4 realms, where nothing should exist, yet you're watched as you travel through the flat land", game.Lighting.voidzoneColorCorrection)
	wasFound = false

So if you put a print on the next line, it won’t print more than once or twice?

Right below for currentPart, section in pairs(workspace.locationChangers:GetChildren()) do, I put “print(‘looped’)” and it runs twice and then doesn’t run again. No errors in the output either. I know the loop is still running because I put a print below while true do and it prints every second

I figured the issue out, one of the parts I had was unanchored and flung itself into the void so there was nothing to loop through lol

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