Kind of a weird question, I want a function to break when a condition becomes true. This is what I was doing:
function foo()
-- should break the function whenever the condition becomes true
spawn(function()
while wait() do
if condition then
return
end
end
end)
-- Stuff the function actually does
end
That return would only break the spawn function though, it wouldn’t break foo. Is there something kind of like this that you can do?
function foo()
-- should break the function whenever the condition becomes true
spawn(function()
while wait() do
if condition then
foo:break()
end
end
end)
-- Stuff the function actually does
end
(Obviously that wouldn’t be the exact syntax, just trying to show what I want.)