Large Part Count & How To Defeat Lag

Story

Hi there everyone!

So my game has almost 40K Parts and 80K Instances in Total, which is not good for lower end devices :disappointed_relieved: & it also lags when I move around and do stuff in Studio which is Annoying and I hate it so much.

But I’m a Scripter so I can Script in a separate place HAHA!

My goal is to open my game to Mobile & Tablet after releasesing the Game to PC first and once it gains popularity.

(I don’t want to focus on too many things at once that is why I am optimizing for PC first but Part count benefits all devices)

Anyways I am pretty sure there are Experienced Devs that has a few Tips/Tricks of there own.

So for my sake, the player’s sake and other Dev’s that has this problem sake, please tell me ways that can reduce lag due to Large Part Counts.

Thank you


Note

I am a scripter so I do not know much about building in fact my Building Skill sucks :joy:

Please remember that I’m not the Builder so I don’t have control over how my Builder builds but I can always guide her to what she should do to help reduce lag, so let me know.

I know that there is no such thing as No lag Script, it’s the most ridiculous thing ever invented because how can more Script Activity = less lag?

What I am already doing

I know some of you will say “Lower the part count”, well my reply to you is “no can do”.
(I mean I can delete Parts/Instances that are unnecessary which is what I am already doing but all the parts that are left are needed for the game)

Most if not all Parts are Anchored.

I already have a plan to Teleport Players (NOT using Teleport Service, just CFrame stuff) to other buildings that are far away from each other. (which leads to my question down below)


Questions

Does putting Builds far away from each other or the origin help?

I will leave a link to a separate game with the builds when I get home (My main game’s closed to visitors atm so Linking it now wouldn’t help + I do not want to leak my game so I will add people that reply to this Thread to the Whitelist :+1:)

16 Likes

Putting builds far away from each other would improve things; however it also has some cons which I will get into after why it is good.

You want to remove as much stuff from memory as possible, as well as reduce the amount of stuff that needs to be rendered.

If you have anchored 100k parts behind you and you are looking forwards at an empty baseplate than you should have significantly better performance than if you were looking at the parts.

Honestly I’m no expert on this area of Roblox at the moment.

If you have builds far away from each other, you will start encountering floating point decimal issues. You should be able to get a good description of that issue by doing a Google search, but essentially it means that numbers like 5.0 and 3.6753 will be defined inaccurately e.g. 4.999999999 or 3.67.
It gets worse the farther you go away from 0,0,0.
It will cause big issues with basically everything, but depending on the size of the game it won’t be important.

17 Likes

I don’t know exactly how your place looks like since you did not provide us a link to it - please do that. It helps us help you.

A solid way of improving performance is to combine a lot of parts to single MeshPart instances where possible. It is not suitable for all collections of parts, but if you can have a single MeshPart instead of ie. 1000 Parts you have a lot to save.
Try to avoid a lot of moving and unanchored parts if they’re not absolutely necessary. Colliding parts are especially bad in that sense.

If all your parts are anchored and opaque (non-transparent), they’re already really efficient.
MeshParts should have CollisionFidelity set to Hull or Box where possible to not store a lot of detailed, unneeded physics data.

The biggest memory hog is very often textures. Meshes with Textures, Decals, ImageLabels, ParticleEmitters, Beams and so on. People tend to use very high-resolution images in places where low-resolution would be sufficient. You do not need a 512x512 image for your ParticleEmitter when a 128x128 or even 64x64 could get the job done. Similarly you do not need a 1024x1024 image for a Beam if it’s so tiny that you could get away with a 64x64.
Reducing the rate of ParticleEmitters could also help some.

You could make a Level of Detail system which shows less detailed models/maps for low-end users and loads in the details for high-end users.
Alternatively (or additionally) you can load in the objects/zones they need to see when they need to see them. MeepCity is an example here; they load in areas only when the player visits them.

You can also consider turning on Streaming for your place. It will help you with the “loading in objects only when they’re needed” by only rendering the objects when the user is close enough. Streaming still has some weird quirks and might require you to adapt your scripts to how it works, but it is worth a try.

These are my top tips. You need to choose what you want to do, and not all tips may be ideal for all types of projects.

37 Likes

@EmeraldSlash @Ravenshield

Game Link Seriously 122 Clicks? You really want to know what this is do you?
I will open it to DevForum members later, only to people who are in the DevForum Group will be Whitelisted.

Please do not leak my game.


Others can’t join the game just you 2 are on the White List, if you have any suggestions or want to discuss about my game please take it to DMs.

You can use these commands in chat

;speed number
;jump number

to move around in game faster

Thank You!

5 Likes

It is quite hard to play on my phone due to performance, yes.
The first thing that strikes me is the size of the map. Does it have to be so big? It feels like you’re just endlessly walking, and bigger also means you need more things to fill. Are you planning to fill in all the empty area that you currently have?

Average memory was at around 440 MB, with Textures taking up most of the memory. Textures took up 313MB out of the 739MB allocated for PlaceMemory. I assume this is mostly the textures from your foliage/bushes, since you have a lot of those bushes (including the “vines” on the buildings behind the dorm). Other than that, it was running at a steady 60 FPS on my computer and I could not see any obvious performance sinks when I explored the level.

6 Likes

So from what I’ve learned about laggy games isn’t necessarily the part count (though that does contribute to the performance) it’s also based on the amount of scripts that are running in your game. A few ways to solve this would be to form unions with your parts, lessening the count.

I don’t know how many scripts are in your game but if there’s more than 20 I would consider putting a few inside of each other that way they aren’t all running separately. (Another helpful tip could be to make your main script a model then make a script to require the main script, I know a few people who have big games and do that and they don’t lag as much because of that)

And the third way would be to add fog, so that way the player doesn’t render the entire map, only a good chunk of it, depending on where they are at.

4 Likes

I would advise against unioning unless your array of parts is supposed to move or otherwise interact physically (not just static collision). Each and every unique UnionOperation needs to be downloaded from Roblox every time you enter the place, which puts additional strain on the client upon startup. Parts are generally lightweight as long as they’re anchored and opaque (or entirely invisible, because then they don’t render).

The amount of scripts also do not usually impact performance that much. The important factor is what the scripts do and how performant (optimized) your scripts are. The script instances in themselves do not cause performance drops, but the executed code might. There’s really no difference in having the ModuleScript local in the place or if you’re loading that from a model, because the source code is loaded in either way.

11 Likes

I have 1 Script 1 Local and 1 Module. Mostly just some more are in tools.

The game has more than that tho due to some models were imported but don’t worry about it, those scripts will be removed.

I actually found like 120 Scripts
Which will definitely be removed.

2 Likes

Well yes it’s a big game but I have plans on making the Player Teleport within the game from a large place to another place which should help with performance.

It’s as big as Robloxian High School I think
how do they not have problems(or less) for Mobile?

One thing that I can think of to increase Mobile performance is to have a Settings that players can turn On/Off which will delete some Details.

1 Like

I can add you to the Whitelist if you want but I can’t do that now, just let me know. :+1:

1 Like

Thank you this really helped me with an issue I was facing with a new map I made.

5 Likes

Unfortunately there are not so many ways to reduce lag, but at the same time it is possible. you have to obviously contain some plugins or elements that increase the lag and how normally you should take them away from the spawn or other main centers of the game.
Also try to get some obviously programmed systems that can reduce the lag, some say that if you post the link of your game it would be possible to help you more by having the experience of lags in your game but you said to dont leak your game, so yeah
also try to check if you have some viruses out there, because they also cause great impact of lag in the servers

anyway try to get more help from other experienced programmers or builders
because lag is a big problem for famous, popular games and etc only if you want obviously a good game very good built and very well programmed

I am aware of this but don’t worry about Viruses they are only a problem for inexperienced Devs, I have a plugin and methods of getting rid of them easily & I don’t use Free Models from unknown Users I only use well known Models or Models from well known Devs.


That’s actually a really good suggestion!


I actually Whitelisted RevenShield & EmeraldSlash, so that’s not a problem


I don’t use Plugins that effects my game I only use Plugins that helps with Developing, so that’s not an issue.

2 Likes

Consider those if your game doesn’t needs these parts to be rendered all at the same time:

5 Likes

I have tried this and it didn’t work well with my current setup but it gave me an idea.

So to make join times faster I would put Most (if not all) Buildings inside my Localscript and then slowly Parent them to the workspace.

Because exploiters can steal whatever is on the Client-Side it doesn’t really matter at this point.


Multi-Place Games , Yes I am already taking Advantage of this. :+1:t2:


Yes About 99% of BaseParts in my game is Anchored.

My game currently has 44K parts. YIKES :scream:


If you are interested to see my current game build then I can add you to the Whitelist. @FieryEvent

1 Like

tl;dr Only optimize it enough to run on newer hardware.

I mean, from my experience playing on an old iPad mini it’s going to be really hard for you to support those older devices. Literally 90% of the games I played on it gave me really low framerate and most even crashed at some point. The only games that worked were (not surpisingly) really low-detailed old games that were made something like 10 years ago and maybe a few obbies. There’s a reason that most of the popular games on mobile are such low quality, being that they’re all a lot of players can really enjoy. There’s probably plenty of kids using ancient hardware, in fact didn’t Roblox say most of their mobile users are using iPhone 5s or something?

Luckily Roblox is working on making rendering parts cheaper so you might want to try optimizing your place to work with that. Also, I think some people believe that using only smooth plastic as a material for parts will help reduce lag (At least the mobile version of Work At a Pizza Place does), so you can try that too.

But seriously, I might be missing a huge market, but I’ve stopped trying to support the older devices. It takes the fun out of developing anything that’s not the absolute most basic (visually) and just makes things so much more stressful. I’d optimize it as much as you can, for sure, but if your grandma’s 10-year-old iPhone can’t run it don’t sweat it.

9 Likes

I agree and I will probably make a Separate game for Mobile/Tablet if not a Setting that will change the Quality of the BaseParts.

I am not trying to overkill optimizing but it’s just better than not optimizing at all.

Atm I am just optimizing for PC and not Mobile/Tablet & XBox because they also need different Guis for better UX.

And it also helps when you are working in Studio and Testing, faster loading time when you need to Test a script or just moving around is less frustrating.

2 Likes

I see no problems to take a look at your game.

Just noting that streaming doesn’t really work like that, the regions far from the player aren’t downloaded by the client until it gets there, exploiters would need to trigger the download to get the map. Parenting can get quite expensive, but I have no true experience on that.

4 Likes

Well I don’t care about my Workspace being stolen I am over it.

Surprisingly when I turned Streaming Enabled on I got less FPS than not turning it on.

The idea is to actually Parent everything to workspace via LocalScript slowly, I might do something like BloxBurg you know how Houses turns into Boxes when you are far away from it and then it becomes a House when you get Closer?, it doesn’t seem like he is using Streaming Enabled. I might asks Coeptus how he does it, he is really nice.


I will add you to the whitelist soon.

5 Likes