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

How do i stop functions on local scripts?

i did a loopuing function and i want yo know a way to stop it.

2 comments

0

looping*

0

add an extra end to stop the looping.

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.