I have a while true do loop in my script and it has a wait(15) in it which is quite long, so if it’s started doing the loop when doneOrLate is equal to true, it will wait until the wait(15) is over before breaking the loop. Here’s the part of my script:
while true do
-- I have code here but no wait()'s
wait(15)
if doneOrLate == true then
break
end
end
STEP 1
You see that plus sign? Click on it. STEP 2
Type in bool value. STEP 3
Click bool value and your done creating it. STEP 4
Last and final step
Just rename it.
local seconds = 15
local howMuchWait = 0.1 -- every 100 milliseconds
while true do
for i=1, seconds / howMuchWait do
--this will break for loop if doneOrLate Variable true
if doneOrLate == true then
break
end
wait(howMuchWait)
end
--this will break while loop
if doneOrLate == true then
break
end
end
Thought its not perfect since it will still wait some time before breaking loop. Minimum time you can set at howMuchWait variable is ~0.03 since its minimum time wait() can wait.
local seconds = 15
local howMuchWait = 0.1 -- every 100 milliseconds
while true do
--put your code here
for i=1, seconds / howMuchWait do
--this will break for loop if doneOrLate Variable true
if doneOrLate == true then
break
end
wait(howMuchWait)
end
--this will break while loop
if doneOrLate == true then
break
end
end