I’m the lead developer (well, scripter) for a group place right now. Recently we’ve been having a lot of reports of lag, and I’m not really sure what is causing it. I’m thinking it’s the map itself, but I wasn’t the one who built it.
Outside of the map itself, there are three possible scripting reasons that may be a reason why it's lagging, but I kind of doubt that
Various loops, such as the Day/Night script that waits every 2 seconds. There is also a script that checks the position of every player every 5 seconds to see which safe zone they’re closest to, which loops through every player and every part representing a “safe zone” (there are about 10 of these parts).
The main script that controls the spells, which is over 3k lines (mostly functions for each spell). The spells are done via CFrame and constant raycasting everytime the RunService.Stepped event fires (only one connection to this event that updates every spell in the game currently moving). But even when I spam dozens of these spells at once, there is only a slight increase in lag.
The spell trail effect, which (outside of a few certain spells) have two trails connected to two attachments. The positions for each attachment is constantly randomized every RunService.Stepped event via a script inside each spell part. The source of which can be found here. But like above, I don’t see much lag from this even when spamming a ton of spells via an autoclicker every 50 milliseconds.
I have a few logs from the Developer Console while in a server of around 25-30 players, but I’m not really sure what most of it means:
Client Memory
I have absolutely no idea what counts as a lot in this case.
If anybody can explain the various diagnostic tools seen above and where the problem seems to be, that’d be highly appreciated.
Alternatively, I could maybe convince the rest of our group leaders to let somebody take a look inside the place itself and/or run some tests (depending on how well known/trusted they are). If anybody here is willing to take the time that is.
You might want to check this wiki post out (Documentation - Roblox Creator Hub) It explains what most of the words that are shown in the logs mean and also shows what’s causing lag in particular.
I’ve had problems with lag in the past and it surprised me what caused the greatest stress on the server. Using the script activity page on the Dev console allowed me to determine which scripts to alter and remove. According to this page any script or groups of scripts above 3% activity are generally bad.
Due to my game being 50 players, the sound scripts in every character caused some stress on the server so I decided to remove it for now, it also prevented the easy sound exploit to shut down servers. In my opinion, a win win action.
Depends on how many remote events, from my experience the more remote events the better. As long as it’s not a stupidly huge amount, but having things running through different remote events decreases lag because when a lot of people fire the same remote event it will start throttling and delaying everything.
Damn, maybe the firing the same remotes at the same time might cause the throttling. And how much would you say is alot of remotes. I think my last game had something over 200.
200 is a bit excessive in my opinion, try to limit it to like 10 or something. What I do though is when a player joins, I clone a script and create a new remote event for the player so they’re the only ones who are calling it and then I have another remote event in ReplicatedStorage to fire all clients so the total amount of remote events in a server would be (Amount of Players + 1).
This is completely off-topic but you can fix said sound exploit by using the RespectFilteringEnabled property in the SoundService. This stops everyone from hearing sounds that a client plays, thus effectively stopping sound exploits. It won’t make a difference however if you have a remote that calls play on a sound that the client defines via an argument, because that’d be the same as calling Play directly on sounds in a non-RespectFilteringEnabled environment.
Also not sure how the Sound script stressed the server. I’ve run 100+ player servers fine with no stress from character sound scripts.
All the tools OP posted in the OP are useful, but the first things you want to be using before any of those are the MicroProfiler or the F9 Developer Console (sift through the tabs). Look for expensive loops running in short intervals. If your place does not have experimental mode on, check your remotes; what they do, who fires then, how often they’re fired and if it can be deemed efficient or not. Of course, there’s more ways to look for lag, but this is generally my process.
Either high latency (i.e high ping) or low frames per second, both are often referred to as lag while being completly different things and having completly different causes.
I’m not entirely sure, but collectively they were using ~10% on average. I made the decision to remove them and server latency reduced rather noticeably. As for the sound exploit, they somehow managed to find a way to overload the replication events which was able to shut servers down almost instantly, this may be patched now but it was quite commonly used over a lot of games.
Heyo! You might want to check out this wiki post if it helps, (Documentation - Roblox Creator Hub) But it would depend how bad the lag is, try RespectFilteringEnabled property