How to maximize you game's performance or increase player's fps

So i want to make my game more optimized and playable even in low end pc
The problem is when your graphics is on its lowest you can barely see anything in the map
When you turn it for like level 4 it will give you a framedrop if your pc is trash

Solutions I tried:

  • I tried placing all the while loops code all in one script so i don’t have multiple loops running
  • We tried to lessen the amount of parts inside the workspace
  • Change the rate for snow particle emitter and set it to low

we tried this stuffs and it helps just a little bit but its still laggy. I checked on the client memory usage and its usually 300 - 500 mb only i wonder whats the problem

You can check the game’s perfomance here and figure out the problem.
game link:
https://www.roblox.com/games/5634881964/Stairs-of-Hell-BETA?refPageId=0eb4b051-728c-4b05-ac49-373b5e8a6f8a

You should really try not to use while loops as much as possible, another tip is try disabling collisions for certain parts the player can’t touch, may help a bit.

1 Like

going to lighting - Technology and then changing the technology to Compatibility, it disables big shadows and makes the game look ugly, but it works

2 Likes

@Boogagle
What’s wrong with while loops?!? The problem wouldn’t be the while loop, but rather whatever code is running inside of the while loop.

@DybalaplaysYT
It would be better to use Voxel instead. Compatibility is only meant to be used in old places that were made with Legacy lighting in mind, and it’s meant to be a temporary solution until the developer can fix it.

1 Like

Not necessarily, if it’s a while true do loop they can definitely get performance heavy. You’re usually better off with a RunServixe heartbeat connection.

I mean, you can go test it yourself and see which one runs faster.

while true do can be used for purposes other than doing something after a yield, so it doesn’t make sense to lump the two together. Even then, Heartbeat would still use a similar (if not the same) amount of resources anyway, and if there’s a difference then it’s unnoticeable.

Functions you have bound to fire on every render step take around two milliseconds (an eighth of a frame, this is a LOT), and various other scripts (all of which are named LocalScript) take up around another millisecond of frame time. On top of this, the player is rendering upwards of two million triangles per frame, which is more than enough to cripple an iPhone X or low-end PC. You have a lot of script and model optimization to do :+1:

There are several helpful resources on the topic of performance in many fields which you can find via the search bar. I’ve written a guide on it here which may help you;

2 Likes

no, while loop is infinite, while loops are bad, it takes memory…
RunService.Heartbeat is way better and you can also disconnect it

While loop is infinite

That’s incorrect. You can always break out of while loops or make them dependent on a statement.

local a = 5

while (a == 5) do
    print('a') 
end
while true do
     print("a")
     break
end
1 Like

never said you can’t break them, but they’re infinite if you don’t break.

You never really said they are bad when you don’t break in that post. Even so, while loops aren’t always infinite if you don’t break.

Refer to this example:

local a = 5

while (a == 5) and wait() do
    print('a') 
end

The while loop will only ever run when a equals 5.

2 Likes

That is a bad practice. Having while loops like this that continuously checks something wastes resources in the background. It’s better if use events.

@UnknownParabellum
I think they chose to do that because they’re just trying to give a quick example.

@varjoy
There’s nothing wrong with an infinite loop. Isn’t using Heartbeat also creating an infinite loop? (keep in mind you can end both loops by (breaking/disconnecting it) And Heartbeat takes memory too. Anything you do is going to take memory.

1 Like

infinite loop its not probably needed, and it takes more memory
since also everyone uses wait() in while loops which is a bad practice

Have you tested that? Even if that’s true, the difference would be unnoticeable. (i’m assuming you’re talking about while true do compared to Heartbeat, since you didn’t make it clear what you’re talking about)
Also, there are cases where infinite loops are
needed, like a day and night cycle that updates to the next time every few minutes instead of updating every frame.

You can also… not use wait? There’s alternatives like this and this. They have functions that serve the same purpose as wait, but without all the problems it has. Also again, not all while loops are infinite wait loops.

you can use run service for day night cycle.

That was just a example… Changed events’ don’t exist for everything.

Don’t forget there is something called manually firing an event when you change the value.