Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is the best way to cut down on lag? Is this answer concise enough?

Asked by
OBenjOne 190
5 years ago
Edited 5 years ago

The bot wouldn't let me put "How should I cut down on lag"

I am planning on a quite large game with lots of scripts and I am worried that this might cause to much lag. One particular script I am worried about is something like this:

  while wait () do
     if script.Parent.Value.Value == true then
         --do something simple like changing a surface GUI or enabling another script 
   end
  end

I wouldn't be too worried if there were just one or two of these scripts in my game, but unfortunately I currently have about 15 of them and am planning on increasing that number to around 50 when I add more content to the game. So far I have not had significant lag, but my computer is probably better than the average ROBLOX player's device. I just need some advice. Thanks

0
Ps. I REALLY like some of the new ROBLOX updates. Especially the server/ client modes on testing :D OBenjOne 190 — 5y
0
Models lag the most, union them and the server won't have to load every instance, just one!! say while wait(.05) do to stop .05th of the lag... The render may be less though. If statements in while loops doesn't really stop lag... greatneil80 2647 — 5y
0
Check Script performance in view to see if any script is causing problem and alot of cpu% Lolamtic 63 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

This is one of my favorite questions.

Here is a list of things you can do to reduce lag:

  1. If you are dealing with camera manipulation do it on the client
  2. If you are constantly changing the camera use RunService
  3. Avoid using infinite loops (while true do loops) if you do not know how to use them properly
  4. When using a loop think about other ways on doing the same thing you want to do.
  5. Use .Changed to detect value changes
  6. Avoid unions there is actually a specific way to use them.
  7. Union repetitive models
  8. Try to reduce part count
  9. Try to not put too much things on the server, if you can do it on client and it's not so important then do so (Game effects, sound effects)
  10. Make sure to debris or :Destroy any new instance when not being used
  11. Always think of alternative ways to do things
  12. When manipulating size of a part, try to use TweenService of for loops
  13. When tweening GUI's, instead of moving the GUI's off the screen, make the invisible as well
  14. Avoid Decals on parts
  15. Try to only have: 3 Server scripts, 3 Local scripts 2 module scripts
  16. Avoid putting :FireServer() on a remote event in a loop

Try these things. I came up with them on the spot

Best of luck developer

0
thanks. I didn't think to use .Changed. OBenjOne 190 — 5y
0
No problem BlackOrange3343 2676 — 5y
Ad

Answer this question