Wait() taking absurd amounts of time

  1. What do you want to achieve?
    My goal is getting wait() times to be fixed, or at least reduced from the massive time it takes now.

  2. What is the issue?
    For some reason anywhere in the game wait() takes around 39 seconds. I’m not sure what is causing this, I have never run into a delay this huge before. I have attached an image of game output showing this happen.

RobloxPlayerBeta_2019-09-02_22-19-51 RobloxPlayerBeta_2019-09-02_22-19-51 RobloxPlayerBeta_2019-09-02_22-19-51

  1. What solutions have you tried so far?
    I tried to set the default wait() speed in the studio settings but that did not fix it since it goes back to taking 39 seconds once the game is ran regardless of the studio value. I also went through and deleted all the unnecessary scripts I could find within the game. I’m not surprised these didn’t fix it, but it was worth a try before coming here and asking for help.

This is the game having the issue: Game Link

1 Like

Does this happen only in that place file or in any studio instance you run?

Do print(wait()) in a Baseplate, what happens then?

2 Likes

It happens only in that specific place. Doing it within a baseplate instead of a part of importance still has the same outcome.

1 Like

What happens if you do wait(0.5)? If you define the wait time instead of relying on the default, does that fix it?

Also, did you restart studio? Some changes won’t take place until a restart.

1 Like

Wait will never wait the exact amount of seconds you specify. When you call wait, what it does is wait for n seconds and then also wait until a spot in the task scheduler is open. If wait is taking 39 seconds, you’re going to want to review your code over and tune it up in terms of performance and efficiency.

6 Likes

Take a look at the script performance window in studio, look for any scripts that are running with a very high activity percentage (usually anything > 5% is something to worry about).

2 Likes

Adding on to this, there are better methods for delaying the thread than using wait(). (refer to Avoiding wait() and why)

As @colbert2677 mentioned, if wait() is taking this long for you, you should revise your code for optimization and efficiency, as this is also a sign that your game is laggy serverwise (which is never a good thing).

1 Like

If wait() is that slow, the rest of the game probably is too.

Are you doing any huge, performance-heavy operations? Are you sure you don’t have a memory leak?

Check the dev console and look at what is hitting your performance the most. From there, you’ll more than likely be able to see what needs to be optimized.

Also, if wait() is taking over 30 seconds, I think it’s doubtful any other yielding methods are going to fair much butter. You need to find the source of this issue instead of using a bandaid fix like replacing wait().