Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 08 May 2016 07:37 PM |
Can someone tell me how I can constantly check and see if "In" is empty, and if it is end the game?
while wait() do local run = false --if false games not running local In = {} --players that survived after game ends local roundTime = 5 --time each round local pn = 0 --players needed to start local im = 5 --intermission time if game.Players.NumPlayers >= pn then for i = im,0,-1 do wait(1) print("games starts in "..i.." seconds") end run = true else run = false end while run do print("starting game...") for i = roundTime,0,-1 do wait(1) print("games ends in "..i.." seconds") end wait(1) print("game has ended") wait(5) run = false end end
-Briicks |
|
|
| Report Abuse |
|
|
|
| 08 May 2016 07:41 PM |
for i,v in pairs(table) do if v then else
?
|
|
|
| Report Abuse |
|
|
|
| 08 May 2016 07:42 PM |
U could use a loop every 5 seconds or so to check if all the players u added into the In table at the start of the round are alive/ingame
Or u could check each time a character dies or player leaves. |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 08 May 2016 07:45 PM |
^ I need it to work with my code above, also would this work?
repeat wait() until #In == 0 then if a player leaves or dies remove them from the table, if the table is empty(0) the game ends
-Briicks |
|
|
| Report Abuse |
|
|
Entelicon
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 1002 |
|
|
| 08 May 2016 07:46 PM |
while wait(5) do if #In == 0 then -- Empty, end game else -- Not empty, players still alive end end
Something like that? |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 08 May 2016 07:47 PM |
i could do that but, the game wont end until all players are dead. i need to game to be like a min and end in that time, or when all players are removed from the table.
-Briicks |
|
|
| Report Abuse |
|
|
Entelicon
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 1002 |
|
| |
|
|
| 08 May 2016 07:52 PM |
i got this
local endGame = Instance.new("BoolValue",workspace) endGame.Name = "endGame"
if #table == 0 then if game.Workspace.endGame.Value ~=true then game.Workspace.endGame.Value = true end end if wait(90) then if game.Workspace.endGame.Value ~=true then game.Workspace.endGame.Value = true end end
game.Workspace.endGame.Changed:connect(function(val) if val == true then --end game end end)
|
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 08 May 2016 07:53 PM |
What do you mean "what?"...
I want it to start the game if there are over let's say 3 players. If there are over 3 players in the game run will be turned to true and the game will start. All players will be put into a table, where if they are killed or leave the game they will be removed from this table. If all the players die, or the game time ends the game is over.
If I use a while wait(5) do to check and see if all the players are dead, the game will never end due to the loop of checking to see if there are still players in the table.
-Briicks |
|
|
| Report Abuse |
|
|
Entelicon
|
  |
| Joined: 06 Nov 2012 |
| Total Posts: 1002 |
|
|
| 08 May 2016 07:56 PM |
spawn(function() end)
That saves lives. |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 08 May 2016 07:57 PM |
I do not want to insert anything into the game. I want everything to be run by the script. If I where to insert stuff I'd be able to do this with no problem.
-Briicks |
|
|
| Report Abuse |
|
|
|
| 08 May 2016 07:58 PM |
| repeat wait(10) until #n==0 --Put this on the line at which you want to stop |
|
|
| Report Abuse |
|
|
Briicks
|
  |
| Joined: 03 Apr 2015 |
| Total Posts: 1796 |
|
|
| 08 May 2016 08:07 PM |
Never mind, I'll find a way.
-Briicks |
|
|
| Report Abuse |
|
|