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

How can i kill a player that touches a block?

Asked by 8 years ago

What do you put into a script to kill a player that touches it and what script do i need to use? The Regluar, the L, or the M?

2 answers

Log in to vote
0
Answered by 8 years ago

The solution is simple, here is the code inside a Server Script.

script.Parent.Touched:connect(function(hit)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    end
end)

If this answered your question, hit Accept Answer.

Ad
Log in to vote
0
Answered by 8 years ago

Better explanation:

script.Parent.Touched:connect(function(hit) -- creates the function, hit is the part that touched the brick (arm, leg, etc.)
    if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then -- if hit is not nil (nil meaning it doesn't exist), and hit.Parent (should be character) isn't nil, and hit.Parent has a humanoid, then continue the script
        hit.Parent.Humanoid.Health = 0 -- hit.Parent (character)'s health is set to 0, hence killing them
    end
end)

Answer this question