i did a loopuing function and i want yo know a way to stop it.
COMMUNITY QUESTION
How do i stop functions on local scripts?
1 answer
Hello,
Hope you are not a beginner at scripting in RbxLua.
Strictly for advanced users of RbxLua.
local thread = coroutine.create(function() -- Creates a coroutine function
for i,v in pairs (workspace:GetChildren()) do -- Table
print(v.Name) -- Prints table
print("Loop suspended on : "..i) -- prints on what loop number it was suspended.
coroutine.yield() -- Suspends loop.
end
end) --ends coroutine function
-- A loop of coroutine.resume functions.
while coroutine.resume(thread) do --On coroutine.yield, this will allow in between actions.
print("Waiting 1 second...") -- Print
wait(1) -- Waiting 1 second.
coroutine.resume(thread) --Coroutine resumes.
end
--Ending of loop.
I am still learning RbxLua.
Thank you for reading.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
looping*
add an extra end to stop the looping.