Wait 5 seconds before moving to scene

Im trying to make a start screen saying to “please view in 1920x1080 res” that lasts for 5 seconds before moving to the next screen.

Before I was using this:

function stateChange(newState) {
setTimeout(’’, 50000);

if(newState == -1) {
alert(‘The games start waring is beggining. Staging for timeout 5000’);
gotoAndStop(2)
}
}

Nothing is working and I am very confused. If anyone knows js please send help my way!

Copy-paste this to the default script in order to go to the next frame after exactly 5 seconds

project.C=new Date().getSeconds();
project.B=0;
onEvent('update', function () {
  if(new Date().getSeconds()!==project.C){
      project.B=project.B+1;
      project.C=new Date().getSeconds();
  }
  if(project.B===5){
      gotoNextFrame();
  }
});
stop();

What this does is, once the project start, set project.C to the number of seconds. If the number of seconds changes, change project.B (the timer) by 1, and reset project.C to the seconds. This way, it’s a never stopping timer in seconds. Once the timer is equal to 5, the project goes to the next frame.

I hope this helps

setTimeout takes a function for its first argument, and it calls the function asynchronously after the amount of time specified in the second argument has passed.

instead of using setTimeout (i don’t think it works how it should, or at all), you can use a frame counter (or a timer if you want to do that). for the frame counter, set a variable to 0. the amount of seconds you wait for is sec * framerate. so if you wait 5 seconds and its 30 fps, you wait 600 frames. in the update tab, increment the variable and constantly check if the variable is greater or equal to the number of frames you want to wait. when it is true, go to the next frame.

thank you everyone for the help! im still mostly new at javascript!