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 needs to be fixed.

Previous Thread :: Next Thread 
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
04 Jun 2014 04:05 PM
This is trying to find if the killer is dead or the bystanders are dead.




local allPlayersDead = false
local bossDead = false


function check()
for i, collect in pairs (game.Players:GetChildren())do
if collect.ClassName == "Player" then
if collect.TeamColor == "Lime green" or collect.TeamColor == "Really red" then
print("Running")
else
m = Instance.new("Hint")
m.Parent = game.Workspace
m.Text = 'Round Over'
wait(60)
m:Remove()
end
end
end
end

repeat
check()
until allPlayersDead or bossDead
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
04 Jun 2014 04:08 PM
TeamColor is a BrickColor, not a String

That loop does not yield so the server/client will crash.
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
04 Jun 2014 04:10 PM
Even if you put a wait() in the repeat until loop, it wont work because you call it every 1/60 of a second and there is a part of the function where it waits for 60 seconds.
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
04 Jun 2014 05:12 PM
doesn't fix it :/
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
04 Jun 2014 05:34 PM
bump
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
04 Jun 2014 05:49 PM
bump 2
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
04 Jun 2014 05:52 PM
allPlayersDead and bossDead never gets updated, hence infinite loop.
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
04 Jun 2014 06:04 PM
I would but idk how to scan if no players are under a certain team the change on of the values
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
04 Jun 2014 06:06 PM
instead of

repeat
wait()
check()
until allPlayersDead or bossDead

use

coroutine.resume(coroutine.create(function()
repeat
wait()
check()
until allPlayersDead or bossDead
end))

so that it doesnt pause the whole script with the loop
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
04 Jun 2014 06:10 PM
I didn't give u the whole script.


later this is ran

while wait(30) do
repeat
check()
until allPlayersDead or bossDead
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
04 Jun 2014 06:11 PM
while wait(30) do
repeat
check()
until allPlayersDead or bossDead
end

Let me explain this. It waits 30 seconds and then sets off a repeat loop. After the loops finishes, you wait another 30 seconds and the loops is triggered again. Is that what you wanted..?
Report Abuse
GlaciesRex is not online. GlaciesRex
Joined: 22 Oct 2011
Total Posts: 1100
04 Jun 2014 06:27 PM
Yes
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