Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i stop functions on local scripts?

Asked by
raulib 30
6 years ago

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

0
looping* raulib 30 — 6y
0
add an extra end to stop the looping. Jxemes 75 — 6y

1 answer

Log in to vote
0
Answered by
arshad145 392 Moderation Voter
6 years ago

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.

Ad

Answer this question