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

Help on A for loop??

Asked by 10 years ago
players = game.Players:GetPlayers()
for i,v in pairs(players) do
                check = game.Workspace:findFirstChild(v.Name)
                if check then
                    hum = game.Workspace:findFirstChild(check)
                    if hum then
                        v.Character.Humanoid.Health = 0
                    end
0
Where are all your ends? Tkdriverx 514 — 10y
0
I put theme all but it still dont work :/ PullAnAllNighter 8 — 10y

1 answer

Log in to vote
0
Answered by
Kratos232 105
10 years ago

Line 5~

It says hum = game.Workspace:findFirstChild(check). It should be something like hum = check:findFirstChild("Humanoid")

You also forgot some ends.

Altogether, it should look something like...

players = game.Players:GetPlayers()
for i,v in pairs(players) do
    check = game.Workspace:findFirstChild(v.Name)
    if check then
        hum = check:findFirstChild("Humanoid")
        if hum then
            v.Character.Humanoid.Health = 0
        end
    end
end

Oh, and if you just want to kill everyone...

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

Well, hope this was helpful at all....

  • Kratos232
Ad

Answer this question