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

2 comments

0

return will stop the function, break will also stop the loop.

0

return only stops the changed event and break isn't useful...