Game becomes more prone to freezing as the game progresses

Hello!
I am from a fairly new dev team and we recently launched a game. This game is about clearing waves where enemies get spawned in and then get destroyed once they are killed. There is a “infinity mode” where enemies keep getting spawned in till the player dies. However, players that are playing on less stable devices, such as older phones, have been reporting that the game becomes more prone to freezing the longer they play.

In theory, the total amount of assets loaded and scripts running is always the same regardless of how far you’ve progressed in Infinity Mode, but in practice it seems that something doesn’t get destroyed properly since so many people are reporting that the game keeps freezing on higher waves.

The way Inifinity Mode works is that enemies are copied from the ServerStorage and inserted into workspace. Each enemy has an “AI” script inside of their model. Once an enemy’s HP is reduced to 0, the enemy gets destroyed using “:Destroy()”. I don’t know if there is something wrong with doing this or if this part is good and it must be something else that is causing the freezes.

As this is a problem that is severely negatively affecting our players, any help would be greatly appreciated ._.

1 Like

Try changing the script to require a module if you’re in the hundreds, in terms of NPCs! That’ll keep your logic in one place where you have more control over the memory leak!