My game crashes randomly

Hello so I have made a game and everything is going well. Its not overly lagging (although I need to work on that a bit), theirs no unusual things happening, accept players crashing seemingly randomly. When the crash happens only 1 person faces it, the others face separate crashes at random times. I don’t know weather this is a client issue or a server sided one. I want to know what causes these crashes and how to stop them. My game has a lot of code, so thats why I decided not to post any, it would be far too much. I have tried checking for loops and I don’t have any malicious scripts in my game (or plugins), so what could be the issue?

2 Likes

Do you have any while true do loops which at no point within their bodies yield? This is a common source of unexpected crashes.

1 Like

Do you have any scripts which load in a lot of data or models suddenly?
Or a local script with an unyielding loop as @Forummer said? because if it’s 1 player facing it at a time it sounds like a client issue but I could be entirely wrong.

no i do not, i can check again to make sure but i dont really use white true do loops, and if i do their usually while wait() loops

Do you have any memory leaks, if you do then that could be the problem

Not sure if this will count but I use Profile Service. I think the module is pretty secure, its open sourced and I haven’t seen any complains regarding crashing from it.

what causes these memory leaks?

Adding to that are you doing any RunService events like RenderStepped, Stepped etc.?

yes i am, a lot of those actually

i use them for my custom wait functions

Memory leak

Then it might be the cause of it. Not confirming it’s the cause but could be. Who knows? Maybe the client has lag, and then it causes the client to crash or something? (Some weird guesses).

Ok then try to remove some to optimize your game

I don’t see custom wait functions causing the problem much, but try using task.wait instead of the custom wait in some places, and check if that fixes it?

Does your game lag when you play it?

ah okay. I was thinking of converting to the task.wait() instead of my custom wait (which uses a run service loop for each). Also in the microprofiler, Worker: RunJob seems to be an issue which i heard is caused from loops and such, so ill give it a try.

1 Like

not really, i have some lag spike issues when i look in certain directions of the map, but that might be caused by buildings. although it seems to stop when i get on my pc. Its also strange that i created an exact copy of my game in another baseplate (including scripts and buildings) and it works fine with no lag

Meaning when you move your camera on that direction? That’s usual.

yea, only appears to happen on my laptop how ever. also the crashing issue is hard to replicate, as i need live players in my game to be actively testing, but ill take into consideration memory leaks and run service functions

One thing that spikes my lag is this:

and this is what the micro profiler shows:

https://gyazo.com/5c16ab3f65b906f7fbde593824bcbeef