Can a while loop stop running? [ Solved]

[Edit: Solved, a repeat until condition function was being used and the script got hung up on that]

So I’m not gonna post the functions since there is a ton of other stuff there connected to. But basically at the start when I run the game. Either “combat” or “order scan” is printed every 0.1 seconds.

After a while though nothing is printed. I don’t really understand how that’s possible since I never changed anything regarding the condition of the while loop.

This script is running in multiple NPC’s, in my case just a test of 5. Is there something that could cause these scripts to break? There was no errors.

while true do
	
	wait(0.1)
	if currTarget ~= nil then
		print("combat")
		combat()
	elseif currTarget == nil then
		print("order scan")
		scanArea()
	else
		print("Nothing")
	end
	
end

you can do

break

woaaaaaaaaaaaaaaaaaaaaah 30 word limit

what do you think while means?
well you can infact break a while loop by doing this

local i = 0
while i < 10 do
i += 1
wait(0.1)
end
print("Broken after 10 iterations!")
local i = 0
while wait(0.1) do
i += 1
if i > 10 then break end
end
print("Broken after 10 iterations! as well")

I meant can a while loop crash even though the condition was still true. Either way I solved the issue already…

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