Weird lag spikes every few seconds

:wave: , whenever you play my game, a massive lag spike that freezes the screen happens every 1-3 sec that basically makes the game unplayable. i have no idea why this happens since i have an exact copy of the game which performs perfectly fine with no lag at all.

streaming enabled is on and i’ve only used maybe 2 free models so i’m pretty sure it isn’t a virus. and if it was, wouldn’t it also lag the copy?

here’s the game:

and here’s the copy which performs fine:

any help would be greatly appreciated!! :slight_smile:

update: i found out the lag was caused by a donation board that i got off the toolbox… the only free model i used was causing it lol. thanks to everyone who gave tips/ways to try and fix it!! :slight_smile:

3 Likes

It’s identical?
Any errors in the Output window?
Have you looked at the script performance to see what script is causing the spikes?
Have you used any plugins that may have inserted a script into something in the game, like the Lighting folder or any other other item with a triangle next to the name of it.

3 Likes

yes they’re the exact same except the copy has a few more parts but the same scripts and everything.
there are a few “infinite yield” warnings but i disabled the scripts that caused those warnings and the lag was still there.
how do you exactly access the script performance?

check for any viruses in your game

1 Like

double check for any hidden viruses too

also i used the ro-defender plugin to check for viruses and apparently it removed 108 viruses but nothing changed. the lag is still there

1 Like

have you checked for scripts specifically with getfenv or require?

1 Like

Infinite Yield is a command style exploit IIRC. It could be that.

Also, the problem sounds to me like a loop. Is any of your scripts by any chance looping through the workspace? (check for while true do loops and repeat until)

1 Like

Which ro-defender plugin did you use?
If it wasn’t made by the original creator then it may be the source of your issues.
@koziahss they’ve stated that this only happens on one copy of their place. If both are identical then any loops should be in both places.

i’m not sure how to do that. could you maybe explain how or link a tutorial?

i downloaded the plugin after i experienced all the lag issues so it can’t be that

i have a few scripts that continually check the time every 5 seconds but i’ve disabled them and tested the game and the lag was still there. plus the copy of the game has those same scripts yet there isn’t any lag

so when your on a script, press ctrl+f and in the search bar type require or getfenv and see which scripts have and dont have them. if its a verified script with require ignore it but if its in a free model DONT ignore it. any script with get fenv is a virus, delete the bit with getfenv and u should be good

1 Like

thanks!! i’ll double check all my scripts. also, if you don’t mind, may you read the update i posted?

Common causes of lag spikes:

  • High quantity of objects/tasks
  • High quantity of loops (while, repeat and for)
  • (Worst case) a virus on your game.
2 Likes

Ok first thing turn off every single script in your game EVREY SINGLE ONE, if the lag persists then check your parts make sure their anchored, or use Render Distance | ROBLOX - YouTube render script which will only show some parts but put the rest in replicated storage I hope this helps solve your problem and please don’t give up hope cause you have a great game

1 Like

Wrap all of your SetAsync() and GetAsync() functions in a coroutine or so. Luau pauses the current thread it’s in. This worked for me.

1 Like

Hey there. I just want to say this is happening with my game. What’s really wierd is that I disabled all of the scripts. Even the default ones and it still has those lag spikes.

After a few seconds it disappears. Only way to prevent the lag spikes is to set the performance quality to 1.

Why does this happen. Does anyone know?

Since this “lag” is on the client it might be your hardware. Mind sliding your specs?

Is this still happening?

Do you have any “while true do” loops and they don’t have a wait?

You could do “while task.wait(seconds) do” instead.