local Players = game:GetService("Players")
local function onPlayerDeath(player)
local allPlayers = Players:GetPlayers()
for _, p in pairs(allPlayers) do
if p.Character and p.Character:FindFirstChild("Humanoid") then
p.Character.Humanoid.Health = 0
end
end
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if character:FindFirstChild("Humanoid") then
character.Humanoid.Died:Connect(function()
onPlayerDeath(player)
end)
end
end)
end)
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
player.Character:WaitForChild("Humanoid").Died:Connect(function()
onPlayerDeath(player)
end)
end
end