Players in my game began to notice lag today. This lag only occurs when a player collides with another object while they are not touching the ground. I did everything I could to try and discover the cause of the lag, but I couldn’t find anything, so I reverted my game to a previous update from yesterday, before the game began lagging. Even after doing this, the game still had lag issues. How are there lag issues now when there weren’t any yesterday if nothing in the game itself was changed?
Make sure the player’s bodyparts collisions are set to box. This could be an issue caused by the Physics, which haven’t been fixed for some reason.
Are you utilizing Ctrl Shift F6 and the Ctrl P hotkeys? This will give you a graph (micro profiler) showing you where lag is coming from each frame.
Could you link the game and/or any relevant videos or screenshots? It’s easier to help you if we know the actual context of the issues or if we get to see them first-hand.
And as TheAmazeman wrote, it might be smart to gather some data from the microprofiler to get an idea for what might be happening.
Microprofiler? Okay, I’ll try that. Thanks guys!
Guys I’ve figured something out! The lag only starts to happen after I do something that puts a Humanoid.Touched connection on my character. Before that happens, there’s no lag at all. But this is still confusing because I use debounces for all of my Humanoid.Touched events so why is it causing immense screen-freezing lag? I even disconnect() the events after their use.
I’m working on a fighting game and 11 of the attacks a player is able to perform involve Humanoid.Touched. Lately I have been noticing screen-freezing lag spikes that weren’t there before and after testing and trying different things to discover the cause of the lag, I discovered that it was caused by these Humanoid.Touched events. The events are firing like crazy when a player enters structures like this: https://gyazo.com/c2a46c884be8e74972dae1404bccf20b or any other structure that has a lot of parts or is moving. I tried disconnecting the events after their use and adding debounces, but this doesn’t prevent the event from firing 10-15 times every time a player is in contact with a part or cluster of parts. Should I just not use humanoid.Touched at all?
Unless it is necessary, try making all those parts belong to a different collision group that does not collide with Default and add one large invisible, non-collidable part that you use the Touched event for.
I also get immense lag any time my character somehow gets stuck in a part. Really confused as to how to fix this. The collision group idea would fix lag for specific parts of the map, but for things such as getting stuck in parts, that wouldn’t be very effective. The weird part is that this .Touched lag only started recently. I reverted my game to older updates, back before the lag existed, and it lags just as much now even on those older versions. This isn’t making much sense to me.
If you can provide us the code for your .Touched events, we might be able to tell you what you can improve.
It could be a memory leak, and that’s why you’ve started experiencing it today.
What’s a memory leak?
A memory leak is where you do not get rid of something that you don’t need anymore, basically.
Your issue could be related to this:
https://devforum.roblox.com/t/upcoming-humanoid-character-movement-change-walking-up-slopes/133354/20?u=baumz
Are you using the new physics solver or the old physics solver? Try switching which you are using and see if the issue persists.
Also, if you could provide a code snippet around the Touched event you are use, we might be able to help you pinpoint a bug in your code causing the lag. If your issues continue, and still do not appear related to your code, make a simple reproduction place with as simple parts and scripts as possible that still cause the behavior you are dealing with. Once you are sure you have found a bug, and can reproduce it, feel free to open a bug report.
I had the same problem too, the cause was PGS Physics being off, upon turning it back on the lag stopped, I’m being forced to use PGS at this point even though its a complete broken mess in my game.
What do you mean by a complete broken mess?
Combos of BodyGyro and BodyPosition keep flinging the character for some reason, BodyVelocity when the player collides literally makes them spring across the whole map, and such…
I’m sure reliable reproductions of those behaviors would be welcome in the big report section. Those behaviors sound non-ideal and I understand why you’d find them annoying.