[SOLVED] Waiting x milliseconds

Hello, i want, after an entity is being enabled, the program wait 1 second before continue, i have tried different things but nothing seems to work as i expect, lastly i tried to put a empty for loop to 0 to 1000 between 1st and 2nd part but i don’t have the result i’m looking for. Any idea?

If async is fine, then use setTimeout, if need a sync approach, then simply:

// set time when starting "timeout"
this.wait = true;
this.timeStart = Date.now();
// somewhere in script update
// if waiting and elapsed 1000 milliseconds
if (this.wait && (Date.now() - this.timeStart) > 1000) {
    // do some stuff
    this.wait = false;

Thanks @max no async is not fine since give me an error (had already tested) the solution you suggest works fine thanks :slight_smile: