JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
|
| 18 Jan 2016 06:15 PM |
So, in my game players are teleported to an arena to fight with swords.
But I'm lacking something pretty big.
When everyone dies, the game keeps playing for the rest of the time.
So how do you make it that if only 1 person is alive, or 0 people are alive, then the game breaks the script?
while true do break end
^ like that break only with the if, then statement to make it so that if one or 0 people are alive, it breaks?
Thanks for helping |
|
|
| Report Abuse |
|
|
JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
| |
|
|
| 18 Jan 2016 06:25 PM |
Make a table with every player in the table and keep track of if someones humanoid dies, their character respawns, or they leave the game If one of those happens, remove their name from the table.
Then in your countdown do this
for x = 300, 0, -1 do if (#tableOfPeople > 0) then wait(1) --[[Do other timer stuff I guess, like updating a display]] else break; end end |
|
|
| Report Abuse |
|
|
JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
|
| 18 Jan 2016 06:27 PM |
| ^ good idea but how would I make a table? |
|
|
| Report Abuse |
|
|
|
| 18 Jan 2016 06:31 PM |
Do you know what a table is? In short; its a list
Roblox has a method under game.Players for getting a table of all the players in the game
local people = game.Players:getPlayers()
Although I would prefer to keep the values as a string like this
local people = {} for _, player in next, game.Players:getPlayers() do table.insert(people, player.Name) end |
|
|
| Report Abuse |
|
|
JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
|
| 18 Jan 2016 10:12 PM |
^ I heard to use a table again.
Where would I put that code? In the global scope or just local? |
|
|
| Report Abuse |
|
|