After resuming a Wait() thread, wait() no longer functions properly.
delay(4, function() coroutine.resume(thread, true); end) while true do thread = coroutine.running(); print("New"); local nt = tick(); if true then local r = wait(1); if r == true then print("Resume A"); else print("Skip A", r); end end local r2 = wait(2); if r2 == true then print("Resume B"); else print("Skip B", r2, tick()-nt); end end
New Skip A 1.0116717000019 Skip B 2.0001374999993 3.0119519233704 New Resume A Skip B 1.0012400000014 1.0012452602386 New Skip A 1.0142976999996 Skip B 2.0144725999999 2.0143115520477 New Skip A 2.018734199999 Skip B 1.0188027000004 1.0188076496124
- First cycle is fine, A yielded for 1 second, B yielded for 2, total of 3 seconds.
- Second cycle, A’s yield was resumed, B then yields for only 1 second when it should had yielded for 2.
- Third cycle, A yields for 1 second, but B says it yielded for 2 seconds but the time only lapsed for 2 seconds shown by the tick() check.
- Fourth cycle, even more bizarre.
Note: I’ve replace wait() with a BindableEvent and it is working like it should.