Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I execute more code after a loop?

how can i run a while or repeat loop while being able to execute more code after that example:

print'called first'

while true do
wait(5)
print'5 second check'
end

print'called last' -- This does not work, I want it to though

i wanna be able to do stuff after the loop, thanks :)

2 answers

✓ Accepted answer

simple.

print('called first')

spawn(function()
	while true do
		wait(5)
		print('5 second check')
	end
end)

print('called last')

I know this is answered already but I'll say another way.

print("called first")

local a = coroutine.wrap(function()
	while wait(5) do -- This is completely valid and saves you a line.
		print("5 second check")
	end
end)

a() -- This is easily forgotten, make sure you do it or else it won't run.

print("called last")

Output:

called first

called last

5 second check

1 comment

0

ur making all hard bro

This discussion is preserved as it was. New answers, comments, and votes are closed.