Game drops frame rate from 60 to <20 FPS over time? (with Microprofiler screenshots)

** What are you attempting to achieve? (Keep it simple and clear)**
I am trying to find out exactly what causes the sudden decrease in frame rate with my game.

** What is the issue? (Keep it simple and clear - Include screenshots/videos/GIFs if possible)**
As soon as you start playing the game, or you reset, the FPS Is at full 60. Then you choose a dinosaur and when you get onto the map, it is initially still at 60 FPS. However if you wait a few minutes, or simply switch into a browser and then switch back into the game, most likely there will be a frame rate drop to 45-40 FPS.
This will then progressively lower itself to 30 FPS, then into the 20-17 FPS regions, maybe over the course of 2 minutes.

Image showing the microprofiler when the lag is present:


It cannot be terrain because I have made my graphics go down to 1 and still get lag.

** What solutions have you tried so far? (Have you searched for solutions through the Roblox Wiki yet?)**

I have experimented with my tool and added destroy() at the end of all of the animations after they stop() because I have read through some of the posts that talk about memory leak, although I am not sure if this issue is what is going on with my game or not.
I have also removed some parts of the scripts within the dinosaur tool and tried it with different scripts, however the problem still persists. Perhaps it may be a script that is still common to both tools?

You may then include any further details.
If anyone knows what the large parts inside the microprofiler means, I would appreciate if they could talk about them, since I am new to this feature.

Looks like a script is not yielding, is it named “Script” or is that the way the microprofiler shows? It seems to be using newindex.

Hi there,
I have since been separating my game scripts down into every possible outcome to determine what the exact cause is,
As far as I know, I have fixed the issue by editing the GUI present at the bottom right corner.

As far as I know, the issue was that the GUI was using a “while wait() do” when it was applying it to the player (this was a free model script, hence why it is to blame) . I have changed it to simply a wait() and so far there is no lag.
It seems that the GUI was constantly adding itself when the game was running, therefore explaining the lag.

Thanks for the reply, though.

1 Like

May we ask what it does? It seems like it is doing some heavy table operations, perhaps some are not needed. Also, you can use debug.profilebegin and debug.profileend to have your custom labels show up in the profiler (so you can debug your application in depth). You can also export the profile captured to a HTML file which all of us can view.

1 Like

Im on mobile at the moment so I cant get the full details, but from what I remember, it was an offset gui that adjusts the camera to the position of each respective dinosaur. It was about an A4 page in length, and with something like that repeating itself constantly, it was ultimately bound to lag.

That’s probably it. You ideally do not want to run an expensive function every approximately 1/30th of a second. You will have to find alternative methods to achieve what the loop is getting at, or increase the interval between when the loop should be run next. Also remember to break any loops that you do not need or set up conditional statements in place of the wait.