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

Would this be suitable to wait for 10 seconds?

Asked by 7 years ago

Would this be suitable and efficient? Or would it be just laggy?

start = tick()
end = tick()
while start - end ~= 10 then
    wait()
    end = tick()
end
print("10 seconds!")
0
Just use wait(10). Perci1 4988 — 7y
2
you can't use "end" as a variable name. 1waffle1 2908 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

There is only one small problem with this, What if the line "start - end ~= 10" is bigger than 10 or skips over 10 seconds.

You probably would also want this as part of a function:-

function chkTime(startTime, limit)
    return tick() - startTime <= limit -- this will return true or false which will be used for the while loop
end

local curTime = tick()
while chkTime(curTime, 10) do wait() end

print('ended')

Hope this helps

Ad

Answer this question