Cancel a yield?

Hey there!
I am the lead programmer on a game called Vington which has not yet been released. Development is going really well so far. I was just wondering, does anyone know of a way to make a “wait” system that can be cancelled when a value changes. For example:

I code a wait(5).
Now say that it has been 2 seconds and a certain value changes. Would there be a way to skip the remaining 3 seconds in the wait() to move to the next line of code?

Please let me know.

wait would halt the thread until the given amount of time has elasped, so there’s no real way to skip a wait without needing to change how your code is organized in the event you need to ignore the remaining time

1 Like

Could you not use an external module for your waits, even though that’d be pretty inefficient? If not for that you can use repeat loops to go until a set value changes or the elapsed time passes, or you could wrap it in a coroutine and check the values but once again there’d be little to no point

1 Like

I think a repeat will work great but I was trying to avoid it

I couldnt just write “for sure” because this forum wouldnt let me. But anyways. For Sure

Would this work

for i = 1, 10, 1 do
if off == false then
elseif off == true then