Such as Murder Mystery when all Innocents have died the game restarts. I do not know the process of that, anyone care to explain/demonstrate?
( I have the code thought out I just am struggling on figured this bit out. Any help would be appreciated)
You would probably need a loop to set all values to true when the game starts:
1 | local p = game.Players:GetPlayers() |
2 | for i = 1 , #p do |
3 | p [ i ] .Alive.Value = true |
4 | print (player.Name .. " is alive." ) |
5 | end |
And while the game is playing:
01 | game:GetService( 'Players' ).PlayerAdded:connect( function (player) |
02 |
03 | local isAlive = Instance.new( "BoolValue" ) |
04 | isAlive.Name = "Alive" |
05 | isAlive.Value = false |
06 | isAlive.Parent = player |
07 |
08 | player.CharacterAdded:connect( function (character) |
09 | character:WaitForChild( "Humanoid" ).Died:connect( function () |
10 | print (player.Name .. " has died!" ) |
11 | player.Alive.Value = false |
12 |
13 | local numPlrAlive = 0 |
14 | local p = game.Players:GetPlayers() |
15 |