|
| 27 Dec 2015 09:31 PM |
| I heard that some scripts can use up a lot of your device's power and causes games to be laggy if they are not made efficiently. What are some methods of making efficient and nonlaggy scripts? |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 09:37 PM |
| A combination of local scripts and variables. You do not want the server to be overwelmed nor do you want the client. Correct me if I'm wrong. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 09:41 PM |
| Woulds using local variables rather than typing a lot into each line make a difference and make the game less laggy? |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 27 Dec 2015 09:42 PM |
Use loops if you need to, but try to use events when you can. When using a loop (especially if it is an infinite loop), don't try to do something really intensive within too short of a pause between intervals of your loop.
Small things (but important) to consider might be using the Destroy method instead of remove. There's things to consider when using FE too, such as trying to avoid doing too many intensive/expensive tasks at once within a server script.
I'd say tootoo was right; you need to try to get a good balance between using Local scripts and Server scripts. You don't want to overwhelm the server or the client, a good balance is just right. |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 09:45 PM |
Let's not do stuff like:
local done = false partA.Touched:connect(function() done = true end) partB.Touched:connect(function() done = true end) while not done do -- Gross loop wait() end print "done"
Let's do:
local done = Instance.new("BindableEvent") partA.Touched:connect(function() done:Fire() end) partB.Touched:connect(function() done:Fire() end) done.Event:wait() print "done"
|
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 09:46 PM |
| So you mean don't overuse wait() unless you REALLY need it? |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2015 10:00 PM |
@spart My thing is waiting for one of multiple events to fire.
Making the bindable and using :wait() basically C-Sides the waiting. Less work on Lua engine (not sure if that's the best wording?} |
|
|
| Report Abuse |
|
|