How can I improve my game's look & performance?

Situation
I’m currently working on my game OOF Hangout which is a “hangout” game that takes place in a nice and small city but also fits with the whole “OOF” meme. I created this game about two years ago, but I recently decided to remake the entire game because I’ve vastly improved my building skills since then. Now that I’ve made huge progress, almost finishing the entire city, I started to notice a few problems having to do with the appearance and performance of the game.

Goal
My goal is for the place to maintain its delightful look and be an enjoyable experience for every Roblox player. I’ve personally only managed to like how the city looks as long as I’m playing within the top three bars of “Graphics Quality” in the Roblox menu bar settings. Anything less than that causes parts and lights to disappear, which is normal, but I dislike it. The only good outcome from me playing at average graphics settings is that my computer fan is not as noisy. I’m aware that the majority of Roblox players are playing on devices such as phones and tablets, and the problem with my game’s quality is way more noticeable there. I just really want the game to look great no matter the device you are playing on, and not by being so dependent on your settings.

Problems
1. Terrain possibly being an issue
My game doesn’t cause lag, but for the best experience, I would only recommend having a device that runs the game well, so ideally, a decent computer will do. I’ve avoided adding too many parts or small details and particles, but I’m sure this isn’t the only thing that can cause performance issues. The following two images are screenshots of the map.


As you can see, there’s a lot of terrain, mostly being water and decorated grass. The thing is, I doubt this is the main problem because I made a copy of the game, removed all the terrain, and tried it out. While playing the copied test game without terrain, I realized my computer fan was still loud, so I’m assuming that in this case, the terrain isn’t the main source of the issue, but please tell me if I could be wrong about this.

2. Disappearing lights
This problem happens regardless of your graphic settings and I was wondering if there is a way to fix it or make it less noticeable. I’ve added a SurfaceLight to every floor in every building in the game, and I was also wondering if this is an efficient way to add lighting. The problem here is that a light source will completely disappear if you’re about 200 studs away from it. I don’t like how bland a building can look if you’re barely that far away from it, and this can be seen in the following images. You’re about 180 studs away from the museum in the first image, and 90 studs away from it in the second.


It may not be so noticeable in the images, as it’s better seen when playing the game, but the museum building doesn’t look good without the lighting that only reappears once you get closer to it. Does adding multiple sources of light solve this issue?

3. Scripts in parts
In this game, all the streetlights have a neon part that turns white when it’s night and turns black when it’s day. This is the script that makes the part change and also activates the PointLight in it:

while wait(1)do
	if(game.Lighting.ClockTime > 6.3)and(game.Lighting.ClockTime < 17.5)then
		script.Parent.BrickColor = BrickColor.new(0,0,0)
		script.Parent.PointLight.Enabled = false
	else
		script.Parent.BrickColor = BrickColor.new(1,1,1)
		script.Parent.PointLight.Enabled = true
	end
end

I realized that there’s more stuff happening when it’s night since every streetlight has a part with the same PointLight and script. This made me wonder about the following questions. Does having many neon parts and/or lights cause performance issues? How can I make one script consistently enable all of the streetlights at once instead of having the same script for every single neon part? Aside from two parts that give a badge when it’s touched and one rotating part, the neon parts in the streetlights are the only other parts that contain a script inside.


4. Part materials
My last concern is using multiple part materials. I already have hundreds of parts that make up the entire city, but I was wondering if giving them all a material can also affect performance issues. I’ve mainly used metal, marble, glass, grass, concrete, cobblestone, brick, neon, and diamond plate parts. I was questioning whether or not using too much glass for windows can cause any problems as well. I’ve seen many games stick to only using plastic parts and still manage to look great, but the appearance isn’t usually the first concern of the developers since it’s more about the gameplay. Jailbreak is a great example of this. If you pay attention, a lot of the builds in that game are actually made of plastic parts. Yes, there are some other materials used here and there, but the game still performs super well, has a lot of terrain, and the map is huge!

My game overall is much smaller than Jailbreak and it still has issues, so what is even causing all the problems for it? Do the materials I use make that much of a difference? Should I just get rid of all the terrain? How can I solve these problems? I’ve added a bit of Blur, ColorCorrection, and SunRays to make my game look a little nicer and I recently tried out DepthOfField, but I feel like my city isn’t looking just as I want it to. I greatly appreciate it if you read all of this and I hope to get some solutions or ways to improve both the look and performance of my game. If you decide to check the game out, feel free to also give me feedback on anything about it! Thank you!

2 Likes

On the third example, simply handle all the streetlights in 1 script rather than having multiple threads of code running.

This may not improve it immensely, but it should lower the lua heap a decent amount.

Try using for loops and searching for the streetlights that need to change.

2 Likes

I didn’t read the whole thing, but throughout you cite your computer fan being loud as a metric of performance. A component’s fan being on doesn’t necessarily mean it’s under heavy load, and you should be using the microprofiler to get an actual reading on performance in your game.

I’m not a builder, but I will say that having a script for every streetlight in the city is totally unnecessary.

Do you have any actual performance problems other than just your fan being loud above a certain graphics level? That might make it easier to pinpoint what the problem is. For example, having a lot of unanchored parts might kill performance. I highly doubt using regular materials such as grass is causing any major performance problems, since your city looks small. Using semi-transparent parts makes the scene harder to render, although it still shouldn’t cause any noticeable problems with such a small build.

We need more information to find the cause of any problems, if a problem does exist. Right now to me it seems that there aren’t any major problems that should be causing noticeable performance drops, but a bit more information could prove me wrong. Your fan being loud isn’t a good enough sign. Things like memory usage, microprofiler stats, etc. will help.

2 Likes

I’ve started to see what a microprofiler actually is, but I’m not understanding it to the fullest. I did some research but I can barely find anything about it. I’m aware that if the orange bar on the top stays low and consistent, your game is performing well. When using the microprofiler in my game, I noticed that occasionally, there were a few spikes. I also have to inform you that I was sprinting around the city and some buildings have more parts than others, so this surely affected it in terms of what I should be able to see on my screen (more parts being rendered at once). I also have a few scripts like background music and two separate ones that allow players to run or sprint. I gathered the following screenshots to give you a view of how the microprofiler looks like while playing my game. They’re all paused at a particular moment because when I zoomed out, every column looked identical.

This was the scene that included lighting effects, shadows, and part opacity.


As I scrolled down a bit and zoomed in, I noticed a lot of smaller chunks.

Here is a glimpse of the other things and some had to do with either updating or rendering something.

I’m completely new to using the microprofiler, but I hope this helped out a bit. For the comment both you and @ViserLizz made about having a script in every streetlight, I have to say that I’m not a scripter and I don’t know how I could make one script enable all of the streetlights at once. Anytime I want something to work, I look up a tutorial and take a view of the code to try to understand it. If I want something so specific, chances are, I won’t find it, so this explains why I haven’t been able to fix that issue. What can I do then?

The microprofiler stats definitely show performance issues, thanks for providing that. It’s still hard to know exactly what is causing those spikes, but as for the streelight script, you can do something like this:

-Tag every light using CollectionService
-Loop through every light using CollectionService:GetTagged()

Here’s a concept of how that would look:

local CollectionService = game:GetService("CollectionService")
local Lighting = game:GetService("Lighting")
local allObjects = CollectionService:GetTagged("Streelight") --get all parts tagged as a light

local BLACK = BrickColor.new(0,0,0)
local WHITE = BrickColor.new(1,1,1)

while true do
    --this should be either true or false, depending on whether or not is day time
    local isDay = ((game.Lighting.ClockTime > 6.3) and (game.Lighting.ClockTime < 17.5)) and true or false
    --go over every light and change properties accordingly
    for key, light in pairs(allObjects) do
        light.PointLight.Enabled = not isDay
        light.BrickColor = isDay and BLACK or WHITE
    end
    wait(1)
end

This isn’t tested, and there are some things you could change such as using a changed event rather than a loop. There are definitely other ways that I would do this, but I tried to keep it as close to as how you did it as I could since I don’t know specifics like how your day/night cycle works.

1 Like

Thank you so much for this! I greatly appreciate your help because this also solved an issue I didn’t mention, which had to do with the lights not turning on/off all at once, so some took half a second to respond and function. This is consistent and does not require me to have a script for every single light! It took me a little while to comprehend the script, but I got it eventually, and I just had to fix one tiny error that I found myself making as well, which was forgetting to type the second letter T in the tagged word.


Again, thank you because this will definitely reduce a big performance issue and not require unnecessary copies of scripts. Lastly, for us to be able to know what causes the spikes in the microprofiler, should I just zoom in and send screenshots of what the chunks say?

1 Like

I’ll be honest, I’m not too sure how I could help you pinpoint exact issues by just looking at screenshots of the microprofiler but it’s still helpful to know that there are indeed issues. You can try having the microprofiler up and walking around the city, then seeing what’s happening when you see a spike. Do some areas of the city spike more consistently than others? Is city area irrelevant to microprofiler spikes? If so, then the issue could be scripts or high memory usage.

Analyzing like that with the microprofiler can help you see if there are certain areas of the map that are causing issues. You might have unanchored parts laying around by accident that you don’t notice. One time, my brother had a build that was causing insane frame drops, and it took us a while to figure out that the cause was a ton of unnoticed unanchored parts.

2 Likes

(I understand that this is an old topic, but I still do think I should mention this.)

Roblox has done all developers a huge favor by choosing Lua as it’s main language. Lua is a very lightweight language that is easily integrated into any application. While yes, Roblox uses a modified version of Lua, it’s still very lightweight, easy to run, and scale-able for many platforms. You shouldn’t worry too much about Lua’s performance impact on your game as it likely isn’t the cause of any performance issues that come up.

I would though, take vastqud’s advice. While duplicating the same script multiple times to different parts would technically work and won’t make a MASSIVE dent in your performance, it is really unnecessary and would be hard to change down the line if, let’s say, you wanted to change the lamp’s BrickMaterial to glass while it’s day.

I also recommend that you try your best to stay away from over-engineering your code. When I say over-engineering, I mean that you shouldn’t do this:

while value ~= 10 do 
    wait (1)
end

and try to do this

wait(10)

(In some cases my example would be invalid, but you get the idea.)
General rule of thumb is to achieve what you need with the least amount of lines as possible.

Hopefully, you can use this advice to your advantage and create more immersive and responsive games down the line.

1 Like