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 » Scripting Helpers
Home Search
 

Re: Infinite Loop

Previous Thread :: Next Thread 
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
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
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
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
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
12 Jan 2014 08:57 AM
"This"
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
12 Jan 2014 08:58 AM
sorry, forgot to put the script in it...XD
its the second post (that script)
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
12 Jan 2014 08:58 AM
nvm... and it is an infinite loop...
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
12 Jan 2014 08:59 AM
I thought it should be, but the script either stops looping or it breaks...
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
12 Jan 2014 09:00 AM
Its breaking. make sure
player.Character is not nil
player.leaderstats exists

And stuff like that.
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
12 Jan 2014 09:01 AM
what i should say is, it works for a little while, then breaks or stops looping...
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
12 Jan 2014 09:02 AM
My argument still holds.
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
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
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
12 Jan 2014 09:03 AM
if player.Character then
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
12 Jan 2014 09:04 AM
above would run if player.Character is NOT nil
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
12 Jan 2014 09:05 AM
also
should i make it char = player.Character instead of local char = player.Character?
Report Abuse
VoidShredder is not online. VoidShredder
Joined: 06 Jan 2014
Total Posts: 1467
12 Jan 2014 09:06 AM
local char is better
Report Abuse
Drybones3363 is not online. Drybones3363
Joined: 16 Aug 2013
Total Posts: 1547
12 Jan 2014 09:27 AM
since it is checking the for char, wouldn't it not work after a while still?
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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