I wanted to know how to make a part of a script where if all the players died then the round ends and resets the timer back to zero.
Round Code:
1 | function roundCountdown() |
2 | for roundMinute = 2 , 0 ,- 1 do |
3 | for roundSecond = 59 , 0 ,- 1 do |
4 | playerNotification( 'Time left!' ) |
5 | playerCountdown(string.format( "%d:%.2d" ,roundMinute,roundSecond)) |
6 | wait( 1 ) |
7 | end |
8 | end |
9 | end |
01 | game.Players.PlayerAdded:connect( function (Player) |
02 | Player.CharacterAdded:connect( function () |
03 | local GameValue = Instance.new( "BoolValue" ) |
04 | GameValue.Parent = Player.Character |
05 | GameValue.Name = "InGameValue" |
06 | end ) |
07 | end ) |
08 |
09 | --The above adds in the "InGameValue" value every time the player spawns. |
10 |
11 |
12 | function CheckPlayers() |
13 | local InGameNum = 0 --The number of players in game |
14 | for _,v in pairs (game.Players:GetChildren()) do --Scroll through players |
15 | local Character = v.Character |
This code goes after you teleport the players:
1 | --Assuming you already have the player under "game.players". |
2 | local PlayerInGameValue = player.Character.FindFirstChild( "InGameValue" ) |
3 | if PlayerInGameValue then |
4 | PlayerInGameValue.Value = true |
5 | else |
6 | print ( "Can not find: 'InGameValue'" ) |
7 | end |
This should work, it does require you to set the value of "InGameValue" located in the player's character to true when you place him in a round though.