✓ Accepted answer
To detect if someone died, you would use the Died event of Humanoid objects.
local t = {}
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:connect(function()
table.insert(t, player)
end)
end)
end)
To check if everyone is dead, it is simply a matter of looping through all connected players and see if someone is missing in the table:
local function isEveryoneDead()
for _, v in pairs(game.Players:GetPlayers()) do
if not t[v] then
return false
end
end
return true
end
if isEveryoneDead() then
t = {}
end
Hope this helped. If it did, please make sure to mark my answer as accepted and optionally upvote; It helps both of us. :)
1 comment
^ Ok, but I would not be asking if I found something.