Huge lag spikes on player join

This depends on the amount of triangales or functions that have been launched to the server. Using unions would help, but you should also optimize your scripts and even don’t use too much Lights(this is one of the most lag producers). If you want to optimize your game, I’d recommend decreasing the amount of instances and objects inside your project.

1 Like

About the scripts part, I disabled every single script in the game and the spike was still there.

I understand the amount of parts can lag the server, but it should lag it always, not only when a new player joins. That’s my logic, tell me if I am wrong.

1 Like

Check what plugins you are using, some of them may send a lot of instances or scripts to your game that may cause lag.

1 Like

Don’t mind Mizaru, it was just a test I was doing.

1 Like

Do you make the game with someone else that uses plugins?

1 Like

Yea, should I try asking them to disable all their plugin and test?

1 Like

Check each of them, maybe one has a virus that causes all your problems

That won’t help, unions are not nearly as efficient as parts nor meshparts. If you have parts, don’t even try to make them into unions, they’re not really useful anymore.

About the topic, inspect each single piece of your game, if you suspect from a specific thing like the map or the lights lagging the thing out, just take them out to another test place and if the lag is still there, well, at least it is not a virus and just a performance problem from you.

I’ll try and let you know.

Thank you all for your time, much appreciated!

Do you have any scripts in StarterPlayerScripts? Maybe some code there could be a virus infecting your game … maybe even free models?

I disabled everything with a command, lag spike was still there.

What functions do you execute on game.Players.PlayerAdded? That might be a cause for the lag if you do a lot on the server.

It’s not my scripts.

I found this in the console.

That’s the cause most likely

Huh, that’s pretty interesting. Not sure what to think about that…

Are any parts unanchored? Or this could also be because you have a lower end computer which can’t handle your map size and assets. One thing you can do is request someone to try it out and see if they have the same problem. If they do not get the same result, then it is your computer’s problem. If they do, then maybe make some adjustments to map size.

But the lag is server-side, not client-side

In that case it must be an issue on Roblox’s end, since Roblox runs the servers.

It’s not a roblox server issue. He’s clearly doing something very intensive on the server or has a memory leak.

@PumpYaK You said this occurs when a player joins right? Check your PlayerAdded/CharacterAdded Connections. Could you provide context to what your game is or what script you think might be the issue? Are there any loops that deal with players? Are you constantly raycast/checking regions around players for a certain system? Are you disconnecting connections once you’re done with them?

We need more context. I suggest going one by one through all your serversided scripts, disabling them one by one → Testing to see if it fixed the issue → if it does review said script → make sure you’re not doing anything to intensive or have any connections which might be causing memory leaks.

What do you mean by “memory leak”, is that some technical term?

Thing is, after i disabled my scripts, the ones with PlayerAdded/CharacterAdded events, the issues was still there.

for _,v in ipairs(game:GetDescendants()) do 
    if v:IsA("Script") or v:IsA("LocalScript") then 
        v.Disabled = false 
    end 
end

I ran this command in the command bar.
This is very weird and it’s not related to my scripts.