Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make the npcs die with the players?

i been trying to figure out how to make the npcs die with the players when the round is over, but can't seem to see why it ain't working

for i, player in ipairs(game.Players:GetPlayers()) do
if player.Character then
local hum = player.Character:FindFirstChild('Humanoid')
if hum then
hum.Health = 0

1 answer

✓ Accepted answer

###Instead of looping though the players, loop through the descendants of workspace.

for _, descendant in pairs(game.Workspace:GetDescendants()) do
    if descendant:IsA("Humanoid") then
        descendant.Health = 0
    end
end

1 comment

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.