Confusing Lag in my game?

I’ve been working on a game with a couple of friends recently, and around 3 - 4 days ago the game has been lagging EXTREMELY bad, and I can’t even replicate it.

Firstly I noticed it was happening when I hit something with my stand, like this:


As you can see, my frames drastically decrease whenever hitting the dummy, though don’t decrease when hitting the air.
I dumbed the issue down to this part of my code:
image
Commenting out the damage.Parent part or anything else fixes the lag completely.
(Yes, literally instancing in a part then parenting it to the workspace is lagging the game)

So, I just removed that part of my code and moved on- yet a couple hours later I saw ANOTHER issue with it, this time with my teleport code:


This also seems to produce frame drops, though I am not sure why.

Now, I’d be fine with this and just draw it out to being an issue with my code, if it weren’t for the fact that this was all working a week ago, and no changes to the effects have been made recently.
As you can see in this gif, there is no framedrops at all:

This was taken roughly a month ago.

Some extra information:

  • This is a Team Create place
  • We use streaming enabled
  • I cannot reproduce this in anyway, it seems to just be localized to this
  • Disabling streaming enabled or testing in a live server does nothing to fix this
  • Other things that are rendered on the client (Like damage counters), do not cause any framedrops whatsoever.
  • Other people (my coworkers and playtesters) are also experiencing this, its not just me.

If you need any extra information or you think you have a workaround for me to try please reply to this post.

If you create numerous parts and you don’t destroy them (or use Debris:AddItem) they will build up and a ton of parts will cause FPS drops.

Makes sense, though this is occurring as soon as the server starts, so its not due to any part buildup, so it probably isn’t because I didn’t destroy them. I’m also pretty sure debrisservice internally destroys them.

Do you have a large map? (30 )

The map isn’t massive, it’s around this big, not sure about the actual dimensions though.


You can get to one end to the other in like a minute or so.

Hmm… Is there anything that happens on server startup?

Nothing that would cause lag- all I do is connect things to .PlayerAdded and .CharacterAdded for rigbuilding and such, no instancing parts or anything is done.

If I had to guess, it’s because you’re running too many things at once without using any wait() in those loops.

Well lag can’t be random, something has to be causing it, does your client memory spike when you join the game?

@wish_z
@ValuedSins
Let me repeat that this is only occurring when I instance a part and parent it to the workspace.effects for making an effect like a teleport. There are no connections to workspace.effects.ChildAdded or workspace.DescendantAdded.
There is no lag randomly happening at all during gameplay with the rendering code in the OP removed, so its all dependent on that.

I would say that this is an engine bug, if I was able to repro it in a separate placefile or separate script, but it seems to only happen in this specific occasion.

Well you’re not instancing 1 part, you’re creating multiple and parenting them. Do you ever destroy these parts? and how long till they’re destroyed if so?

If your talking about Move.DamageParticleAmount in the for loop, this generally only runs once and doesn’t run multiple times. If it does its at small amounts like 3 or 5, sometimes bigger depending on the move.

By looking at the explorer with this code enabled, only one part gets added and gets removed after 3 seconds (I commented out that part of the code because it didn’t hold any relevancy to the lag, but it is not commented out in the actual game)

Hello, I assume your lag is based on excessive tweening on server-side.
Or, it might be because of physics rendering calculation.

Is the script serverscript? If it is, it’s an extremely bad practice to put tweening inside for _ do loop since server memory will be used excessively and cause performance issues such as FPS dropping.
Instead, use RemoteEvent for your case. You can fire RemoteEvent to the server when player is punching, and the server fires RemoveEvent to all-clients; which is not involving the server to do any heavy calculation.

Please give me a little feedback about this after changing your tweening with this method.

Sadly, I wish that was the case.
I actually AM doing rendering on the client, that is actually a snapshot of my main Client script, with the second one being a screenshot of my other script that receives the remote event and does the effect.
Main reason why its so confusing to me, as I’m not doing anything relatively intensive, and it was smooth a week ago.

What changes you made within a week? And also I believe you are tweening in for _ do loop in second script too.

To the first one, a decay parameter was added, though after removing it nothing changes.
The second one has always worked fine until now and hasn’t been changed whatsoever.

Did you test alone at a week-ago moment and are you testing with more than 2 players now?

The game has a few testers, so we have been testing with multiple people since the start.
So, the game ran smoothly a week ago, now it does this.
I’m 99% sure this is a Roblox bug, but I can’t reproduce it anywhere else but in this exact occurrence, so it wouldn’t be easy to add a repro so anyone could figure out what was causing it.

Would you mind trying commenting tweening line of your code in serverscript and run a quick test?

Sry for the complete necropost but did u ever find out what caused it? im having the same problem, no childadded/removed connections or anything but when anything gets parented/removed to the workspace, theres a fps spike. ive been digging and cant find any solutions. if u have any idea pls reply thank u