Hello everyone!
My games are lagging very hard,
thats why I wanted to ask you if it
is somehow possible to reduce lags.
Yes it is. Review your code and try to see where you are performing inefficient activities. Could you try providing a more specific scenario in which youâre encountering lag or perhaps do a bit of debugging first though? This question is vague and something that can be answered elsewhere. For the purposes of the forum, you should be asked a detailed question about a specific case.
As an add-on to @colbert2677âs question, what exactly is making the game lag? it could be chunks of code that could be shrunken done to boost performance, it could be too many meshes or parts.
As colbert said, you should be more specific with the question youâre asking, then others can give you a more accurate answer.
There are a lot of ways you can reduce lag. Before creating a new thread you might want to look into other threads with the same topic. But @TypeByte Is right.
It might not also be a script. A picture of a topic a friend and I had a while ago.
If heâs referring to this particular game than it shouldnât be for the following reasons:
- Itâs an official template by roblox, all that was modified from first glance was the GUI design and modifying the original skybox.
- Iâm relatively certain this is more of his computer being the issue rather than the build or code itself. Though at the same time the template mightâve not been fully optimized for gaming performance.
Unanchored parts are simulated by the physics engine. That still is related to coding in a minor sense, but on the whole itâs related to performance.
Servers can implicitly see what theyâre given. The client does not have itâs loading time increased with larger unions, nor does this affect performance.
Part count can be resolved with streaming or chunk loading solutions. Thatâs pretty much what the fourth point suggestions but in a vague sense.
One stud walls can ruin immersion or the aesthetic aspect that multi-part walls can achieve. Not always a viable solution.
When it comes to the realm of performance, itâs a very specific topic isolated to different contexts within the game. Yes itâs possible to reduce lag but the lack of information from the OP prevents any useful discussion since we have to dig around for the circumstances first.
Helpful knowledge is in the air but itâs useless if itâs not applicable to OPâs situation. @PermanentGamer1 Please explain your situation in actual details rather than asking a vague question.
Things that Cause Lag
1. Having too many parts.
- As @PrincessUSA_Dev has stated, having too many parts causes lag. (this is why games with large maps like âWestover Islandsâ lag a lot.)
Remove Parts that arenât necessary to the gameplay. Use more parts and fewer
Unions. Use decals to create flat areas.
2. Viruses or Infections are Hidden in Your game
- Viruses are those annoying things that we try to avoid during our everyday Roblox life. Different viruses cause different issues but a majority of them cause lag and server sided exploits to your game. How are infections obtainable?
- Fake Free Models
- Fake Plugins
Here is a very useful plugin to find these malicious back doors.
Here is the actual plugin: Hidden/Infection Script Detector - Roblox
3. Your Scripts Need some Re-doing
- @colbert2677 has covered most of this:
Try making your scripts more efficient! Here is an example.
Bad code that causes studio to crash:
while true do
instance.new("part")
end
Instead do this:
while true do wait(1)
instance.new("part")
end
Please check the Developer Hub first for help with general principles:
https://developer.roblox.com/learn-roblox/optimization
Good luck with your games!
Unions actually donât reduce lag at all but in some cases they can increase the amount of lag. It is better to have 2000 parts than making it one union.
As other people have said, the question is very vague. We need more information on what parts of your game is lagging (Building, Scripts ect). Please follow the format About the Scripting Support category @PermanentGamer1
Lag can be caused by may things in a game including badly optimised scripts, lots of badly optimised builds and free models. Some free models can cause lots of lag because they may have hidden loops that cause huge amounts of lag, badly build objects that create lots of lag, ect.
How to optimise you scripts for better performance(less lag)
Lots of common forms of lag from scripts is loops. Lets say you want to move a part you shouldnât use a loop to move it as huge amounts of lag will be made but instead use TweenSerice. The moral of the story is donât use a loop if you donât have to use it but instead use less laggier alternates like TweenService.
If you game has to insert huge objects like maps you may want to put them in ReplicatedStorage or load the map in separate chunks. If you put the map in ReplicatedStorage the map will already be loaded onto the client and then when you insert it into workspace the lag when inserting it should be reduced. You could also put Filtering Enabled on to help reduce the lag of loading in objects as well.
How to optimise your builds for better performance(less lag)
There is a huge amount that can be done to reduce lag with your builds so I am not going to name all of them.
A very common cause of lag is with having lots of unnecessary parts in your game. The more parts in your game the higher the games memory. If you reduce the part count while maintaining the detail then your games lag should reduce. Here is a small example:
As you can see in the image below their is a total of 9 parts that make up this window. The part count of this can be improved while keeping the look of the build the exact same. This is made up of:
-2 window parts
-3 middle posts
-4 parts for the top and bottom
As you can see in the image below the part count has been reduced by 3 parts meaning that this build is made up of 6 parts rather than 9. All I have done is make the glass only one part and the bottom and top parts only 2 parts. Here is the new part counts:
-2 Parts for the top and bottom
-3 central posts
-1 glass part
This ties in with building and scripting. If their is lots going on in your game like explosions, lots of parts moving, lots of decals and images lots of lag can be created. The client has to render everything it sees meaning that you have lots going on it is slower to render.
Here is a great topic about building optimisations that you may want to read:
Whether to use Unions or Parts is dependent on the game, and one is not better than the other.
As the original post is so vague, itâs very difficult to give meaningful advice, as any number of things could be causing it. It could even be completely unrelated to efficiency altogether - projectiles with no network owner set can appear to âlagâ as they switch between owners, or it could just be that the OPs game does not account for latency.
The OP should either be looking at the developer hub for reliable guides on what to do, or make a more specific post.
Please ask specific questions in development support to avoid back-and-forth discussion like this.
Follow the format for future support posts:
Please also mention your level of skill in future posts so that people have a rough idea about what kind of help you are looking for