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

Why doesn't it kill the character?

Asked by 4 years ago
Edited 4 years ago

Killer = script.Parent Killer.Touched:Connect(function() game.Players.FindFirstChild.Humanoid.Health = 0 end)
0
I'm still new, and I am willing to learn NicoXerocious 29 — 4y

1 answer

Log in to vote
2
Answered by 4 years ago

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.

0
Killer = script.Parent MiguRB 60 — 4y
0
What? Theswagger66 54 — 4y
0
Variable names are supposed to be lowecase, and every next word begind with a captial letter: likeThisYouBagel iSpaceRBLX 31 — 4y
1
Also, your spacing hurts, please fix it. iSpaceRBLX 31 — 4y
View all comments (2 more)
3
@iSpaceRBLX if you're not accurately contributing to the discussion, don't comment dude. Psudar 882 — 4y
1
@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. Theswagger66 54 — 4y
Ad

Answer this question