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 Prevent Lag...

Previous Thread :: Next Thread 
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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 is not online. 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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
19 Jan 2016 08:01 PM
So what are some ways to prevent lag?
Does using :Destroy() instead of using :remove() help?
Report Abuse
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
19 Jan 2016 08:07 PM
Bump
Report Abuse
TimeTicks is not online. 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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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 is not online. 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 is not online. 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
checkplate is not online. checkplate
Joined: 05 Jan 2016
Total Posts: 1379
19 Jan 2016 08:21 PM
What about scripts that use that conditionally locally? For example a script to move a model?
Report Abuse
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
19 Jan 2016 08:39 PM
What is the smallest wait that wouldn't cause lag?
Report Abuse
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
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
xNitrospeedx is not online. xNitrospeedx
Joined: 05 Sep 2011
Total Posts: 189
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 is not online. 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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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 is not online. 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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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
RaulChaser is not online. RaulChaser
Joined: 07 Dec 2014
Total Posts: 655
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
Crazy010517 is not online. Crazy010517
Joined: 17 Sep 2011
Total Posts: 1161
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
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