Adjunto propuesta Class Lock:
antes de establece el valor
/**
* Get Methodos Class Lock
* @returns {errorclass} Metodhs Class Lock
* @see Class Lock:
* https://developers.google.com/apps-script/reference/lock/lock
*/
const classLock = LockService.getDocumentLock();
/* https://developers.google.com/apps-script/reference/lock/lock */
classLock.waitLock(30000); // 30 seconds
let azar = Math.random()*5;
Después de establecer el valor
resetFormat.copyTo(rangoOrigen,SpreadsheetApp.CopyPasteType.PASTE_FORMAT, false);
/* Releases the lock, allowing other processes waiting on the lock to continue */
classLock.releaseLock();
Referencias:
Lock Service
Class Lock