If you compute the delay before the buffing then the „lock“ is not needed, since the delay is handling that. The problem is that current implementation is calculating the delay after buffing, which I think results in running the script twice before the delay does what it should do.