|
| 12 Jan 2014 08:56 AM |
This Is Not An Infinite Loop because of the for...do Can someone change this to make it become an infinite loop? |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 08:57 AM |
function survivor() for number,player in pairs (game.Players:GetPlayers()) do local char = player.Character if char.Head.Position.Y < 434 and char.Humanoid.Health > 0 then local name = player.Name player.leaderstats.Points.Value = player.leaderstats.Points.Value + 25 player.leaderstats.Survivals.Value = player.leaderstats.Survivals.Value + 1 char:MoveTo(Vector3.new(-350.27, 2791.43, -96.31) + Vector3.new(math.random(-10, 10), 5, math.random(-10, 10))) end end end
while wait(1) do if script.Parent.ScorePart.CanCollide == true then survivor() wait(3) end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Jan 2014 08:58 AM |
sorry, forgot to put the script in it...XD its the second post (that script) |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 08:58 AM |
| nvm... and it is an infinite loop... |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 08:59 AM |
| I thought it should be, but the script either stops looping or it breaks... |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 09:00 AM |
Its breaking. make sure player.Character is not nil player.leaderstats exists
And stuff like that. |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 09:01 AM |
| what i should say is, it works for a little while, then breaks or stops looping... |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Jan 2014 09:03 AM |
how would i find that its a nil value? I know leaderstats always exists because its on the screen telling me |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Jan 2014 09:04 AM |
| above would run if player.Character is NOT nil |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 09:05 AM |
also should i make it char = player.Character instead of local char = player.Character? |
|
|
| Report Abuse |
|
|
| |
|
|
| 12 Jan 2014 09:27 AM |
| since it is checking the for char, wouldn't it not work after a while still? |
|
|
| Report Abuse |
|
|
|
| 12 Jan 2014 10:38 AM |
if char.Head.Position.Y < 434 and char.Humanoid.Health > 0 then
Due to how conditional statements work, you can simplify this and check for the 'char's existence in that line of code by adding it first:
if char and char.Head.Position.Y < 434 and char.Humanoid.Health > 0 then |
|
|
| Report Abuse |
|
|