script.Parent.Touched:Connect(function(hit)
if script.Parent:FindFirstChild("Humanoid") then
script.Parent.Humanoid.Health = 0
end
end)script.Parent.Touched:Connect(function(hit)
if script.Parent:FindFirstChild("Humanoid") then
script.Parent.Humanoid.Health = 0
end
end)
✓ ANSWER ACCEPTED
Why am i not dying when i step on the brick?
4 answers
✓ Accepted answer
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then -- hit.Parent the thing that hits it the parent of it so the player then find humanoid in the player
hit.Parent.Humanoid.Health = 0 -- same here
end
end)
1 comment
0
dang it I didn't see this
You put script instead of hit.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)
Try this.
local damage = 100 --Default damage for lava based objects.
script.Parent.Touched:Connect(function(object)
if object.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid:TakeDamage(damage)
this script will make it work!
function onTouched(hit) local human = hit.Parent:findFirstChild("Humanoid") if (human ~= nil) then human.Health = human.Health - 100 end end script.Parent.Touched:connect(onTouched)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
You need to find the humanoid on the hit's parent, not on the block that is being touched.