|
| 19 Jan 2016 07:59 PM |
| Well, I never though my game would lag, but after I ran an ad last night and I have several full servers, I realized that my game is a bit messed up sometimes. The lag would make it so that "wait"'s would be a lot longer. For example, a wait(3) would become like wait(10) or something. And physics also become laggy... Any suggestions? Is it because my game is FilteringEnabled? |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 19 Jan 2016 08:00 PM |
| Its because its roblox. You can always check if data is being sent to the server like 10000 times per second. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:01 PM |
So what are some ways to prevent lag? Does using :Destroy() instead of using :remove() help? |
|
|
| Report Abuse |
|
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 19 Jan 2016 08:08 PM |
| :Remove() is deprecated. Use :Destroy(). could be because of too many parts and too many things being sent to the server |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:10 PM |
Okay also, is game.Debris() better to use than Destroy()? Because it destroys it after a certain amount of time with me having to do things like
wait(5) part:Destroy()
I feel like game.Debris is so much better because you would always have to type coroutine.resume(coroutine.create(function() wait(5) part:Destroy() end))
since there might be things happening in that 5 seconds. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 19 Jan 2016 08:11 PM |
| Debris wouldn't be necessary in this case. :Destroy() should be sufficient enough. |
|
|
| Report Abuse |
|
|
Tomarty
|
  |
| Joined: 08 Dec 2008 |
| Total Posts: 591 |
|
|
| 19 Jan 2016 08:19 PM |
The best way to prevent lag is to AVOID SCRIPTS THAT LOOK LIKE THIS AT ALL COSTS!!!!!!!!!!:
while true do wait() -- do stuff end |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:21 PM |
| What about scripts that use that conditionally locally? For example a script to move a model? |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:37 PM |
Oh my god.
That might be why it lags.
I have several scripts that loops and have wait() in them.
So how do I replace those scripts? What would have the same effect as while true do wait() end? |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:39 PM |
| What is the smallest wait that wouldn't cause lag? |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:42 PM |
| I dont know how you would really replace all, but maybe you can replace some of them with events. Other than that, you would probably have to reconstruct a lot of code |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:42 PM |
| The smallest wait should just be wait() with no parameters. It's usually close to 1/30th of a second |
|
|
| Report Abuse |
|
|
Tomarty
|
  |
| Joined: 08 Dec 2008 |
| Total Posts: 591 |
|
|
| 19 Jan 2016 08:50 PM |
The idea is that you shouldn't need to use while loops, and that everything can be event-based.
Basically, a script like this:
while true do wait() label.Text = value.Value end
Should be written like this:
value.Changed:connect(function() label.Text = value.Value end) |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:51 PM |
What about "for" loops?
And what about things like adding 100 parts to Workspace? I guess you could make it event based, but it's not very practical... |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 08:56 PM |
| For example, I have a script that makes a part spin around another by constantly changing the BodyPosition in the part by using a "for" loop. How can I make it event-based? |
|
|
| Report Abuse |
|
|
Tomarty
|
  |
| Joined: 08 Dec 2008 |
| Total Posts: 591 |
|
|
| 19 Jan 2016 08:59 PM |
| There's nothing wrong with the idea of loops, the problem is with scripts constantly doing redundant checks 30 times per second |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 10:13 PM |
| So how do I get the same effect as loops that contain "wait()" without using wait(). Like events wouldn't really work since, there is 0 wait time. I want some. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2016 10:45 PM |
| Don't overuse repeat scripts. Plus Debris will help. And there are a few settings on Roblox studios that may speed up gameplay |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2016 09:45 AM |
| @Tomarty in your game, "Malformed CFrame Animations", what did you use to constantly make the plants move and not have it lag? |
|
|
| Report Abuse |
|
|