Game Optimization ideas and techniques

Hey fellow developers! I recently released my first fully “functioning” experience, and the feedback has been… well, let’s just say insightful! The game is very simple, you kill zombies, drag them back to the camp and burn them to get coins. Despite the games simplicity and complete lack of content, to be honest embarrassing how laggy and unoptimized it is.

The game is having significant memory, CPU, and GPU usage, (1105mb/s, 34ms and 32ms… over double recommended usages in all aspects according to this guide about the micro-profiler). As a self-taught scripter without any professional programming experience, I’m not familiar with standard optimization techniques. My past projects have mostly been personal experiments and failed attempts at games before running out of motivation and switching to the next project, so I didn’t focus much on best scripting or world-building practices or really use any of the dev tools Roblox provides other than the Output.

For those of you who have faced similar challenges, I’d love to hear about any techniques, resources, or experiences that have helped you improve performance and adopt best practices. I recently came across a really good guide by MrChickenRocket on optimization that was both helpful and enjoyable to read, especially around optimizing world assets and touching on some good scripting considerations, check that out here!

In terms of next steps, I’m debating whether to rebuild the game from scratch with optimization in mind or to try and optimize my existing work. I now have a clearer vision for the game as a whole so a lot more consideration can go into creating a more cohesive framework while also planning performance budgets and using the techniques I’ll learn in the coming days. On the other hand, it has taken me a while to get to where I am and rebuilding from scratch would be a large undertaking, so should I spend that time salvaging the patchwork I currently have. What would you recommend?

Thanks in advance for any advice, resources, or stories you can share! I’m excited to learn more about game development and scripting as it really is what i love doing, and I appreciate all the guidance.

2 Likes

Hey! Congrats on releasing your game, it can be quite underwhelming when you get negative feedback from the game you’ve worked a lot of time on, but you should not focus on these negative feedbacks as hating, more like constructive criticism.

Now to ur question: It all depends on how simple the game is. I am not sure how long you’ve worked on the game, but if it’s as simple as you say, you might end up better rewriting the game keeping optimization in mind as you go along. Otherwise if you’ve worked a lot on the game, you might want to just identify, and patch each issue one by one.

But first of all, you should go and figure out what IS causing the lag. Just because your game is laggy, it doesn’t mean that the whole game is bad. It could simply just be one single script that is making it unplayable. Memory leaks can be hard to detect sometimes, but gladly we have tools like the MicroProfiler to help with that issue.

If you do decide to rewrite your game, be sure to focus on things such as connecting events at the right time, disconnecting them after you’re done using it, minimize your RemoteEvent calls, and basically your code’s integrity as a whole. Try and build up your game as different small parts / modules, and connect them together for your entire game. Although a small performance change, if your game requires creation of parts a lot of times (like guns for example), you might want to use Object Pooling to improve performance a little bit. It’s concept is pretty simple: Upon game startup, create a lot of parts somewhere in your game that the player can’t see, and instead of creating a new Part instance every time, you just simply get the objects from the pool and position them to where they are supposed to be, and give them the necessary functionality. Although i haven’t used this, i found a promising module for it.

As some last words, i’ll give you a couple modules that i (and a lot of other people) use to help with memory leaks:
Janitor
Maid
Trove

2 Likes

For most of the part, first technique is to optimize code itself, is to write redable one, try to use types, comments, format it, use full names and split it into smaller bits that can be reused, this will help you optimize your game a lot

Second technique is to write smarter code, more efficient code sometimes tend to be total failure and simply thinking twice about your system may be crucial, because sometimes you find another way to create something

Third technique is to not micro optimize, micro optimizations are usually matter of few seconds and aren’t that important unless you perform math milion times per second

Fourth technique is about cleaning up stuff, memory leaks can be easily avoided sometimes, you can’t avoid them 100%, roblox’s core scripts provoke them too sometimes (Path finding service for instance) and you need wait for them to be fixed, but overall destroy unused stuff, disconnect connections and clear tables soo they will be GCed

Fifth technique is about remotes, see many people use remotes too much because someone said that you need to do everything visual on client or everything important on server, this is true but not always, also think twice before you make soo called “server optimization”

Sixth and last one is to think outside the box, sometimes problem isn’t your scripts itself, but game structure like models, meshes, assets, gui, even service settings, try to learn about optimization for those, and you should be fine

Good luck with fixing your game anyways, i wish i could helped :}

1 Like