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

How can I kill all players at once?

Asked by 5 years ago

I want to kill everyone at once.

I have this so far:

game.Players.Health = 0

doesn't work though

2 answers

Log in to vote
1
Answered by 5 years ago
local function killEveryone()
    local allPlayers = game.Players:GetChildren()
    for i = 1, #allPlayers do
        allPlayers[i].Character.Humanoid.Health = 0
    end
end
0
I agree with vamik. You only posted the code, not explaining anything at all. piRadians 297 — 5y
0
I would say this is a good answer, but it is just spoonfeeding, next time try to explain the code and maybe i'll give you an upvote instead of a downvote... turtle2004 167 — 5y
Ad
Log in to vote
4
Answered by
valchip 789 Moderation Voter
5 years ago
Edited 5 years ago

Hello Hydroxygen4Humans,

So your script doesn't work for osme reasons. game.Players is a service. .Health is a property of Humanoid. Basicly you are trying to set the service's health to 0 which is wrong.

for i, v in pairs (game:GetService("Players"):GetPlayers()) do
    v.Character:FindFirstChild("Humanoid").Health = 0
end

^ that right there is a generic loop, we are going through each index of the table game:GetService("Player"):GetPlayers() which returns the table of the players. Then we are changing each index's humanoid health to 0, the index is the player (v).

Answer this question