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

Why won't this kill script work? :C

Asked by 10 years ago
function Fire()
    print("Slow Kill!")
    local players = game.Players:GetChildren()
    for i=1,#players do
        if players[i].Character ~= nil then 
            print("...")
            players[i].Character.Humanoid.Health:TakeDamage(1)
            end
            end
            end

while wait(.5) do
Fire()
end

Also, can you please see if there is a more efficient way of doing this? There probably is and i'm just stupid.

2 answers

Log in to vote
1
Answered by 10 years ago
players[i].Character.Humanoid.Health:TakeDamage(1)

You use TakeDamage() on the Humanoid, not the health. So

players[i].Character.Humanoid:TakeDamage(1)
0
It still won't work... EzraNehemiah_TF2 3552 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
function Fire()
    print("Kill em all!")
    local players = game.Players:GetChildren()
    for i=1,#players do
        if players[i].Character ~= nil then 
            print("...")
            players[i].Character.Humanoid.Health:TakeDamage(100) --simple mistake
            end
            end
            end

while wait(.5) do
Fire()
end

It works but you're only making them take 1 damage. When you need 100 to kill.

And for a more efficient method I would do this:

function Fire()
    for i, v in pairs(game.Players:GetChildren() do
        if v.Character then
            v.Character.Humanoid.Health = 0
        end
    end
end

while wait(.5) do 
    Fire()
end

now for a slow death:

function Fire()
    for i, v in pairs(game.Players:GetChildren() do
        if v.Character then
            repeat v.Character.Humanoid.Health = v.Character.Humanoid.Health - 1
                wait(.1)
            until v.Character.Humanoid.Health = 0 -- may be a double = im not sure. I don't use repeats alot
        end
    end
end

while wait(.5) do 
    Fire()
end

0
Oops, I wanted it to kill them instantly, but then I wanted them to have a slow death... EzraNehemiah_TF2 3552 — 10y
0
Ohh if you want that you can use a repeat until. I will add it so you can see YellowoTide 1992 — 10y
0
Edited YellowoTide 1992 — 10y
0
Thanks! I'll test it out. EzraNehemiah_TF2 3552 — 10y
View all comments (2 more)
0
I saw some mistakes, like at line 2. (game.Players:GetChildren(). You need another ")". And at line 6. You need "==". You use "==" if you are comparing something. The health regen also made it slower. I deleted it. Thanks again! EzraNehemiah_TF2 3552 — 10y
0
Ummm... It won't loop. After the player dies, it stops. EzraNehemiah_TF2 3552 — 10y

Answer this question