When disabled, it stops the script. When you enable it, it runs the script from the start.
Just like when you enter a game.
does that stop the current thread?
Yes, it will stop any threads/loops.
from my understanding you need a timer that can be interrupted.
local Start = os.clock() -- get current time
while Flag do -- Flag is a variable so the timer can be stopped before time is up.
task.wait() -- doesn't have with the issues wait() has
if os.clock() - Start >= Time then -- check the current time minus the start time is greater than or equal to the time to run for
print("Timer finished!")
break -- timer ran for full duration
end
end
if not Flag then
print("Timer was cut short!")
end
some of the other answers are way over complicated for a simple timer and can be hard to understand later when you want to make changes. By the way, runservice and its different events are explained here: RunService