I have this Teleport countdown that can be cancelled but when I cancel it, the loop seems still running.
This is my first solution:
task.spawn(function()
while task.wait(1) do
if not isTPCancelled then
MAX_TIME -= 1
if MAX_TIME == 0 then
RequestTP:FireServer(true, {"this is my data", 1337, true})
break
end
TPCounter.Text = MAX_TIME
else
circularTween:Pause()
break
end
end
end)
This is my current:
TPThread = coroutine.create(function()
TPCounter.Text = MAX_TIME
for count = MAX_TIME, 0, -1 do
TPCounter.Text = count
if isTPCancelled == true then
circularTween:Pause()
coroutine.close(TPThread)
break
end
task.wait(1)
end
if isTPCancelled == false then
RequestTP:FireServer(true, {"this is my data", 1337, true})
end
end)
coroutine.resume(TPThread)
I don’t know how to handle coroutines yet so please help me.