Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
|
| 23 Jul 2014 09:00 PM |
So as soon as this part of the script runs, the game lags so much. I would like to know why and if there's a fix. I scripted most of it and I can't figure out what's causing all the lag.
players = game.Players:GetPlayers() knifer = players[math.random(1,#players)] knifer.Role.Value = "knifer" kniferknife.Parent = knifer.Backpack gunner = players[math.random(1,#players)] gunner.Role.Value = "gunner" gunnergun.Parent = gunner.Backpack info.started.Value = true TeleportLocation = Vector3.new(0, 0, 0) Position = Vector3.new(game.Workspace.Map.Spawn1.Position) PlayersInGame = game.Players:GetChildren() for i = 1, #PlayersInGame do PlayersInGame[i].Character:MoveTo(TeleportLocation + Position) wait(1/30) end for lol=180,0, -1 do wait(1) info.timer.Value = lol end knifer.Role.Value = "" gunner.Role.Value = "" knifer.Backpack.Knife:remove() gunner.Backpack.Knife:remove() info.started.Value = false end until nil
Thanks alot |
|
|
| Report Abuse |
|
|
Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
|
| 23 Jul 2014 09:00 PM |
| PS: It's only part of the script so the script alone doesn't work, I'm just looking for ways to optimize the script. |
|
|
| Report Abuse |
|
|
Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
| |
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 23 Jul 2014 09:28 PM |
| What's the point of the "until nil" line at the bottom if you don't have a "repeat"? Try taking that out. |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 23 Jul 2014 09:29 PM |
dont do (repeat) until nil
use a while loop |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2014 09:30 PM |
| @smiley599: Real advice please. repeat-until is different from while-do and has a different purpose. |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 23 Jul 2014 09:32 PM |
...
not in this case
He's doing repeat until nil which is the same as while true do
WHENS NIL NOT GOING TO BE NIL |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 23 Jul 2014 09:33 PM |
| Except that he's not even using a repeat because the word "repeat" isn't anywhere in that script. |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2014 09:38 PM |
@smiley599: So why does it matter?
If you are going to say "No do not use A use B which does exactly the same thing with no less work" then give a reason. |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 23 Jul 2014 09:39 PM |
I think it looks nicer with an end rather than until nil.
yeh im nuts |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2014 09:40 PM |
| That is not a valid reason. |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 23 Jul 2014 09:40 PM |
| omg why you being so mean all of a sudden |
|
|
| Report Abuse |
|
|
Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
|
| 24 Jul 2014 11:53 AM |
| I removed the repeat and until nil. The game still lags alot at that part of the script :/ |
|
|
| Report Abuse |
|
|
Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
|
| 24 Jul 2014 11:58 AM |
| Okay, after eliminating parts of the script, I concluded that the teleport section of the script caused the lag. Any fixes? |
|
|
| Report Abuse |
|
|
Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
|
| 24 Jul 2014 12:09 PM |
This part makes the lag:
TeleportLocation = Vector3.new(0, 0, 0) Position = Vector3.new(game.Workspace.Map.Spawn1.Position) PlayersInGame = game.Players:GetChildren() for i = 1, #PlayersInGame do PlayersInGame[i].Character:MoveTo(TeleportLocation + Position) wait(1/30) |
|
|
| Report Abuse |
|
|
Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
|
| 24 Jul 2014 12:23 PM |
| Nevermind, the teleport isn't what's causing the lag O_o |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 24 Jul 2014 03:04 PM |
| How long is the whole script? |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 24 Jul 2014 03:09 PM |
It's inefficient, so imma fix it anyway
TeleportLocation = Vector3.new(0, 0, 0) Position = Vector3.new(game.Workspace.Map.Spawn1.Position) PlayersInGame = game.Players:GetChildren() for i = 1, #PlayersInGame do PlayersInGame[i].Character:MoveTo(TeleportLocation + Position) wait(1/30)
becomes
PlayersInGame = game.Players:GetPlayers () for i,v in pairs (PlayersInGame) do PlayersInGame[i].Character:MoveTo (Workspace.Map.Spawn1.Position) wait () end
|
|
|
| Report Abuse |
|
|
Powerhalo
|
  |
| Joined: 16 Jun 2010 |
| Total Posts: 1504 |
|
|
| 24 Jul 2014 03:28 PM |
| Thanks guys. I found out what lagged the game and fixed it :D |
|
|
| Report Abuse |
|
|