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

How do I make it stop the function from carrying on?

Asked by 4 years ago

Basically, I want the function to stop when the event fires. It fires, but it doesn't stop the event. Please help.

local timerOn = false
function startTimer(team)
    if not timerOn then
        timerOn = true
        spawn(function()
            currentTeam.Changed:connect(function()
                timerOn = false
                return

            end)

            for i = 0,timer do

                print(i)
                wait(1)
                if i == timer then

                    print("worked")
                    timerOn = false

                end

            end
        end)
    end
end
0
return will stop the function, break will also stop the loop. killerbrenden 1537 — 4y
0
return only stops the changed event and break isn't useful... RBLX_Nat 18 — 4y

Answer this question