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
This is one of my favorite questions.
Here is a list of things you can do to reduce lag:
- If you are dealing with camera manipulation do it on the client
- If you are constantly changing the camera use
RunService
- Avoid using infinite loops (while true do loops) if you do not know how to use them properly
- When using a loop think about other ways on doing the same thing you want to do.
- Use
.Changed
to detect value changes- Avoid unions there is actually a specific way to use them.
- Union repetitive models
- Try to reduce part count
- 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)
- Make sure to debris or
:Destroy
any new instance when not being used- Always think of alternative ways to do things
- When manipulating size of a part, try to use
TweenService
of for loops- When tweening GUI's, instead of moving the GUI's off the screen, make the invisible as well
- Avoid
Decals
on parts- Try to only have:
3
Server scripts,3 Local scripts
2 module scripts
- 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