Killer = script.Parent
Killer.Touched:Connect(function()
game.Players.FindFirstChild.Humanoid.Health = 0
end)
Why doesn't it kill the character?
1 answer
First of all you'll need to gain access to the player's character in order to take their health away like so(I'll assume its a normal script):
Killer = script.Parent
Killer.Touched:Connect(function(hit) -- hit will be whatever has touched the part (e.g left leg, etc)
if hit.Parent:FindFirstChild("Humanoid") then -- we need to make sure it was a character
hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health - 100 -- Takes all their health.
end
end)
Any errors will likely be on your end, e.g not placing the script in the appropriate place.
6 comments
Killer = script.Parent
What?
Variable names are supposed to be lowecase, and every next word begind with a captial letter: likeThisYouBagel
Also, your spacing hurts, please fix it.
@iSpaceRBLX if you're not accurately contributing to the discussion, don't comment dude.
@iSpaceRBLX yes I am well aware of “Camel Casing”. “Variable names are suppose to be lowercase” i didn’t know my code would error if I didn’t follow this rule. Thanks for the insight really appreciate it.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
I'm still new, and I am willing to learn