generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How to deal with lag

Previous Thread :: Next Thread 
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 02:31 AM
I'm generating a maze so there are a lot of parts being made at once.
How do I prevent that from lagging?
Now I am generating around 250 parts and then wait a second, but that lags pretty bad


Report Abuse
FloweryMonkeyboy5 is not online. FloweryMonkeyboy5
Joined: 19 Sep 2012
Total Posts: 528
17 Jun 2017 07:24 AM
You could try to use a couple of coroutines to create your maze. You can always use at least 1 but multiple could be an option depending on how you made your code.
Report Abuse
Vyxinph is not online. Vyxinph
Joined: 03 May 2017
Total Posts: 12046
17 Jun 2017 07:26 AM
whyy
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 08:21 AM
@Flower
What do coroutines have to do with this?

@Vyx
Because mazes.


Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
17 Jun 2017 08:35 AM
Coroutines would probably only make it more laggy... There are a few other things you can do though, but I can't garantee it will make that much of a difference:

1. First set all of the properties of the part and only parent it to workspace or whatever after you don't want to change anything to that part anymore. The engine only processes the properties(it still requires a bit of computing power though) when it's inside of workspace, so you save computing power if you don't make it load the default properties first.

2. Try cloning parts as much as possible, every line of code takes up computing power and if two parts have the same properties, just clone that part instead of creating a new one and setting its properties again.

3. Don't use assets if not necessary, the same counts for union operations.

4. If there is a print in your loop that prints a lot of stuff in the output, just remove it, in scripts that already take up a lot of power(like yours probably) you really can't use a print in there.

5. Minimize the amount of calculations. I'm especially talking about magnitudes and stuff, I don't know if you use them, but the less calculations you have to make, the better. If you reuse some number, it's also a lot better to store that number into a variable rather than calculating it again. And do not forget to always use local variables!

6. Check script performance. It's a window you can open in studio, check the percentage for the script that generates the maze. Obviously, you want to keep this percentage as low as possible. The wiki recommends staying below 3%, but I reckon you can pull off going to about 30% without noticing any lag. Rather than inserting 250 parts and waiting 1 second, try using the smallest wait() and see how much parts you can insert each time without exceeding this 30%(or whatever percentage you find doable).


These are some tips that could help, but in most cases, the reason for lag is just because that's all the engine can handle...
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:22 AM
1) Already doing
2) Not doing that yet but shouldn't make a difference.
3) Yup, not using anything extra
4) No prints
5) No complex calculations, always using local variables
6) Yes but how to achieve it? Also last time I tested creating part and wait() created much more lag


Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:23 AM
Thanks for the tips though, you clearly put a lot of effort in them :)


Report Abuse
packid851rb is not online. packid851rb
Joined: 28 Dec 2016
Total Posts: 120
17 Jun 2017 09:24 AM
Try to compact the script. While it takes less room and is more convenient, you must make sure it works about the same as the previous script. ##### lags the most, while computer is the fastest. You should make sure it's on computer and that your internet connection is strong. If both are fine and it lags, try new things.
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:26 AM
Well the thing is that the script doesn't lag at all, it's the rendering engine that makes the player lag terribly when a lot of new parts are made.


Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
17 Jun 2017 09:27 AM
The last one is a bit of a trial and error thing. I have made some scripts that needed a lot of computing power as well and for me, the smoothest way I could get it was using a wait() every few parts.

Also, is the lag staying after the script is finished? Or does it never finish? If the lag remains after it's finished, I don't think there is a point in optimizing, because that just means roblox can't handle it.
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:29 AM
Once the script is done, there'll be so many parts that when you join the game your screen turns white and you either close ROBLOX with task manager or do a hard reboot.


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
17 Jun 2017 09:32 AM
generate the maze locally and make sure the player is in the place before you start generating it?
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:34 AM
@Ag
Might work but then again, how do you deal with the lag generated from moving all those parts to the workspace?


Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
17 Jun 2017 09:34 AM
If the lag stays after the parts are inserted, it's either because there are way too many parts for roblox to handle(in that case you can't do anything about it, except for making your maze smaller) or the script got stuck in an infinite loop. However, roblox implemented this stack overflow error recently, the game used to just crash if you had an infitine loop without a wait, but now it stops the script instead.

But I can't imagine that your maze uses so much parts that it crashes, you must be using over 100,000 parts for that to happen I think, if not more. Maybe put a line in that counts the parts? Maybe your script is inserting more parts than you intended?
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:36 AM
I'm not sure how many parts there are but I'm guessing somewhere around 50K


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
17 Jun 2017 09:36 AM
how massive is your maze???
Report Abuse
Vyxinph is not online. Vyxinph
Joined: 03 May 2017
Total Posts: 12046
17 Jun 2017 09:38 AM
confused
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:40 AM
https://www.roblox.com/games/869780052/Extremely-huge-maze-generator

So massive that when you put your graphics on the highest settings it will only render like 3/4 of the maze because the rest is to far away.
The maze is 9600x9600 studs.

There are in total 120x120 cells with each cell being around 1-2 parts each.


Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
17 Jun 2017 09:41 AM
I'm about to make a big mistake by joining the game haha
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:42 AM
I have a GTX 1050 so and I lag bad but its acceptable for a maze.
Just think like every 3 seconds 1 second stutter.


Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:44 AM
@Harry
So how'd you like my maze generator? xd


Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
17 Jun 2017 09:45 AM
Woah it is massive! It looks very cool, but there is indeed lag. I didn't stay for the whole map to load because I think my computer would fry anyway. But for the time I've been there, there was only lag when new parts got inserted. I don't know how long it takes for it to load completely, but the first minute all the lag is there due to the script.
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:46 AM
Yes, it'll lag for 5 minutes and then it's over.
Then it plays butter smooth unless you change your graphic settings.





Report Abuse
HarrySnotte is not online. HarrySnotte
Joined: 27 Jun 2011
Total Posts: 2854
17 Jun 2017 09:46 AM
I've only got a GTX 630m haha
Report Abuse
GNUnotUNIX is not online. GNUnotUNIX
Joined: 05 Feb 2012
Total Posts: 15171
17 Jun 2017 09:48 AM
Oh yeah if you wanna try the script for yourself:
https://www.roblox.com/library/868782869/Open-Source-Maze-Generator

I made some edits so that:
1) The maze looks like grass
2) Optimizing it for making big mazes

But for smaller mazes that script will be perfect :)
Anyway I generated a maze per example (like an eigth of the size of that other maze) and then copied it, stopped playing the game, disabled the script and then pasted the maze in this game:
https://www.roblox.com/games/868530398/Huge-Maze

So if you wanna see a cool maze that won't fry your PC then there's the place :p


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image