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?
COMMUNITY QUESTION
How can i kill a player that touches a block?
2 answers
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.
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
