There's lots of optimization tricks that games use in order to stay performant, but I thought I'd try and highlight the ones which aren't incredibly case-specific. Within this tutorial, I will cover some programming and non-programming optimization tricks that will help your game.
Unions are great for combining two parts together, but more parts in a game always impacts performance. To help reduce this performance impact, you should put the union part's "RenderFidelity" on "automatic" instead of "precise". This makes it so that the look of the union will change depending on how far away the player is from it, instead of always maintaining the same quality. This will help performance on all devices, and assist lower-end devices especially. To change the RenderFidelity of a union part, click on it, and then look for the "RenderFidelity" property and change it to "Automatic".
Collisions are an important part of every game, so why in the world would they be on this list? The answer is that your game still has to calculate the collisions for a part. Disabling the collisions of a part that the player is unable to ever touch/reach is something you should always do, even if how it changes performance is barely noticeable. To disable collisions on a part, click on it, and then search "cancollide" in the property search bar, then click the checkmark and make sure the square is black.
You should always use
Why? Well, task.wait() updates faster, and is more accurate. The performance difference may not be exactly noticeable, but there is no reason to not use task.wait() over wait().
Now, I'm certain every programmer on Roblox has heard of Instance.new, but are you setting the parent propety correctly? Setting the parent like this
local part = Instance.new("Part", game.Workspace) part.CFrame = Vector3.new(10, 10, 1) part.Name = "CoolPart"
is the worst possible way to use Instance.new. By setting the parent this way, and then assigning more properties after the fact, you're making it so the server has to then do all of those changes and replicate them instead of the part just spawning in with those changes already done, and then replicating. If you simply assign the properties before assigning the parent like this
local part = Instance.new("Part") part.CFrame = Vector3.new(10, 10, 1) part.Name = "CoolPart" part.Parent = game.Workspace
all of those issues and extra work for the server disappear.
I hope this tutorial was helpful, and helped anyone learn something new. Small things like these can really go a long way for your game, and be very helpful for the performance. Best of luck on your develpoing, and have a nice day!