I'm trying to make this loop;
repeat wait(.1) print(check) if check == 1 then W = 0 break end until wait(W) or check == 1 or L == 1
(W, check, and L are all defined somewhere in my script beforehand, and W = 3 btw), and I was trying to make it repeat that code, UNTIL 3 seconds had passed, or check or L = 1. I then found out it repeats 1 time, then finishes after 3 seconds. So I then tried a while loop as while wait(W) do, thinking it would wait that time and run the code below until the time had passed, but it has the same issue as the repeat loop. Also the loop wont break if it only reads once. If anyone knows a way to have this loop last a period of time, comment or answer something if you wish. Thanks.
local s = os.clock() -- os.time() works too, this is just a number thats always incrementing upwards. repeat -- code until os.clock()-s > 1 -- one second has passed. I am basically repeating code until the current time is greater than the previous time
local t = 0 repeat wait(.1) t+=1 -- assuming this is ran 10 times, we wait .1 seconds before it adds again meaning when t is 10, 1 second will have passed. if t == 10 then break end until
Note that there are more than 2 methods, I just listed popular ones with examples I made on the spot, pretty sure you could do polling or coroutines or some hacky workaround but these are nice ones to use