|
| 27 Nov 2014 06:29 AM |
| Could anyone give me a basic idea or something on how i could check that if theres 0 players on a Team that it skips a wait()? |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Nov 2014 06:59 AM |
http://wiki.roblox.com/index.php?title=NumPlayers
game.Players.NumPlayers
*returns a number so assign a variable to is
playernum = game.Players.NumPlayers
*keep in mind that this value can change so you may need to update the variable ever so often or before you launch a function |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 07:03 AM |
| Ok so i got NumPlayers down, so how couuld i skip a wait? |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 07:03 AM |
| what do you mean skip a wait? |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 07:08 AM |
| Like lets say theres a Murderer Round going on (just an example). And if the Murderer Kills all the Players and Theres still time left it skips past all that time (the wait(), and restarts the round. Thats basically what im trying to do. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 07:28 AM |
| Uh Hello? Where'd everyone go (xD) |
|
|
| Report Abuse |
|
|
| |
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 27 Nov 2014 07:47 AM |
Well the timer would be in a loop I suppose, to add a second and wait a second each iteration? Add an if statement in a loop that has the keyword "break" in it if it's true. "break" stops the loop and it will fall-through to the code beneath.
You could also have the condition in the loop as well, which is probably better, so: while timer > 0 and #game.Teams.Team1:GetChildren > 0 do wait(1) timer = timer - 1 end
Not sure if that's how you'd get the number of players on a team though. I've never used ROBLOX's teams for anything. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 07:55 AM |
I tried this for it :
while timer > 0 and #game.("Alive Security"):GetChildren > 0 do wait(1) timer = timer - 1 end
As you can Imagine it didnt work (xd). But what you said Earlier, does a Break autmatically skip past a wait? If so then i just need to Determine how Many Players are on a Team, and if theres 0 to skip the wait). |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 27 Nov 2014 07:58 AM |
| No, break ends a loop. Like I said, you probably have a loop that's handling the timer. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 08:06 AM |
| So what was wrong with my above Script? |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 27 Nov 2014 08:09 AM |
| "Alive Security" is a child of "Teams", first of all. You also did not initialize "timer" I'm guessing, and like I said, I'm not sure if you can get the number of players on a team by getting the number of entries in the table GetChildren() returns when called on the team. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 27 Nov 2014 08:10 AM |
I accidentally forgot the parenthesis that come after the method, so I suppose I'll rewrite it for you.
local timer = 5
while timer > 0 and #game.Teams["Alive Security"]:GetChildren() > 0 do wait(1) timer = timer - 1 end
|
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 08:20 AM |
I tried this but 1 issue. It didnt do a wait of 70, it just skipped over it and went right on to the next line. Also it took no care in how many players were in alive security. Would i have to make the timer a wait? Heres what i used :
local timer = 70
while timer > 0 and #game.Teams["Alive Security"]:GetChildren() > 0 do wait(1) timer = timer - 70 end
|
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 27 Nov 2014 08:36 AM |
local timer = 70
while timer > 0 and #game.Teams["Alive Security"]:GetChildren() > 0 do wait(1) timer = timer - 1 --subtract ONE second from the timer end
If this code is running before there are any players on "Alive Security" than it's going to skip right over this loop. |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 08:42 AM |
| Ok so i did what you did @Above, but it just skips over the line of code. |
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 27 Nov 2014 08:44 AM |
| "If this code is running before there are any players on "Alive Security" than it's going to skip right over this loop." |
|
|
| Report Abuse |
|
|
|
| 27 Nov 2014 08:53 AM |
I this the only way for this to work?
|
|
|
| Report Abuse |
|
|
lordrambo
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 20628 |
|
|
| 27 Nov 2014 08:56 AM |
| Well it should be in your game script, which should be waiting for there to be enough players. I don't think you know exactly what you're doing to do all that though, and I'm not going to do it for you. |
|
|
| Report Abuse |
|
|
| |
|