|
| 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 |
|
|
|
| 26 Apr 2015 03:34 PM |
| You have to stop the second loop using break |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2015 04:18 PM |
I stopped second loop using break It still wouldn't work. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
|
| 26 Apr 2015 05:25 PM |
| Exactly what I said on the SH site. |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 26 Apr 2015 09:02 PM |
| its not while wait() do its while wait do |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2015 09:06 PM |
| Try changing the second "while wait() do" to "while not Ready.Value do wait()" |
|
|
| Report Abuse |
|
|
| |
|
| |
|
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 |
|
|