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

Is there a way to stop a function almost immediately?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

Is there a way to stop a function almost immediately stop a function even if it is currently running. I have been looking on the wiki but theres nothing.

I know theres a :disconnect() for a debounce, but is there anything for a :disconnect() or something for a function() like maybe..

time=10

function TEST() 
for i=time,0,1 do
print(i)
if time==5 then TEST:disconnect() end
end
end

TEST()

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

return exits a function (optionally with a value).

time = 10

function timer()
    for t = time, 0, -1 do
        if time == 5 then
            return
        end
    end
end

timer()

I'm not exactly sure why you're doing a loop like that, though. You should count down to just 5 if that's what you mean to say.

Ad

Answer this question