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 » Scripters
Home Search
 

Re: Loop is not working correctly

Previous Thread :: Next Thread 
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
26 Apr 2015 03:26 PM
So the script is supposed to detect how many players are on a team and if the amount of players on a team changes or not. So if there wasn't enough people on each time (the minimum is 1 player), it would print a message. But if the teams suddenly got enough players, it would begin the game, and vice versa.

The script worked before, and now it's not working, and I have no idea why. Everything is defined. Can someone please help me?

Here's the script:

local Ready = script:WaitForChild("Ready")

local team = game.Teams;

function getPlayers(teamColor) -- team color is easier than name
local found = { };
for _,v in pairs(game.Players:GetPlayers()) do
if v.TeamColor == teamColor then
table.insert(found, v)
end
end
return #found
end

while wait() do
print('Starting game')
wait(5)
while wait() do
local greenNum = getPlayers(BrickColor.new('Bright green'))
local redNum = getPlayers(BrickColor.new('Bright red'))
if Ready.Value == false then
if greenNum > 0 and redNum > 0 then
Ready.Value = true
else
print('Nope')
end
end
end
if Ready.Value == true then
print('Starting game...')
end
end
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
26 Apr 2015 03:34 PM
You have to stop the second loop using break
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
26 Apr 2015 04:18 PM
I stopped second loop using break
It still wouldn't work.
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
26 Apr 2015 05:01 PM
bump
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
26 Apr 2015 05:23 PM
b2
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
26 Apr 2015 05:25 PM
Exactly what I said on the SH site.
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
26 Apr 2015 06:04 PM
@goulstem

Call me a skrub but I tried using break and it didn't fix the issue
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
26 Apr 2015 08:21 PM
bump again
Report Abuse
xXRevengeCreeperXx is not online. xXRevengeCreeperXx
Joined: 22 Nov 2012
Total Posts: 699
26 Apr 2015 09:02 PM
its not while wait() do its while wait do
Report Abuse
TipOfTheIceSpear is not online. TipOfTheIceSpear
Joined: 16 Apr 2015
Total Posts: 30
26 Apr 2015 09:06 PM
Try changing the second "while wait() do" to "while not Ready.Value do wait()"
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
26 Apr 2015 09:18 PM
@TipOfTheIceSpear

Still no
Report Abuse
CoolJohnnyboy is not online. CoolJohnnyboy
Joined: 09 Mar 2010
Total Posts: 17699
27 Apr 2015 04:25 PM
bump3
Report Abuse
treebee63 is not online. treebee63
Joined: 16 Aug 2010
Total Posts: 376
27 Apr 2015 08:41 PM
while wait() do
print('Starting game')
wait(5)
repeat wait()
local greenNum = getPlayers(BrickColor.new('Bright green'))
local redNum = getPlayers(BrickColor.new('Bright red'))
if Ready.Value == false then
if greenNum > 0 and redNum > 0 then
Ready.Value = true
else
print('Nope')
end
end
until Ready.Value == true
if Ready.Value == true then
print('Starting game...')
end
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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