Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a script recognize when all players have died?

Asked by
reaper5 10
11 years ago

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)

1 answer

Log in to vote
2
Answered by
Dummiez 360 Moderation Voter
11 years ago

You would probably need a loop to set all values to true when the game starts:

1local p = game.Players:GetPlayers()
2for i = 1, #p do
3    p[i].Alive.Value = true
4    print(player.Name .. " is alive.")
5end

And while the game is playing:

01game:GetService('Players').PlayerAdded:connect(function(player)
02 
03local isAlive = Instance.new("BoolValue")
04isAlive.Name = "Alive"
05isAlive.Value = false
06isAlive.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 
View all 31 lines...
0
Thanks reaper5 10 — 11y
0
+1 reaper5 10 — 11y
Ad

Answer this question