Kill block not working

I have created this kill block but it does not work if possible please spot the error! Thanks in advance.

local part = script.Parent

part.Touched:Connect(function(touch)
	if touch:FindFirstChild("Humanoid") then
		touch.parent.Humanoid.Health = 0
		
	end
end)

Also nothing comes up in the output.

I don’t know if this is the problem but you forgot to capitalize parent. Maybe also add a print to test it:

local part = script.Parent

part.Touched:Connect(function(touch)
	if touch:FindFirstChild("Humanoid") then
        print("Touched by: "..touch.Name)
		touch.Parent.Humanoid.Health = 0
	end
end)
1 Like
if touch:FindFirstChild("Humanoid") then

That line is attempting to find the part that it actually touched I believe (Left Arm, Right Leg, etc) so it’s skipping through the if statement

You could replace that line with

if touch.Parent:FindFirstChild("Humanoid") then

To see if it makes any difference? Cause the parent is the character alone whenever it gets touched

2 Likes

That is practically the same as my code. It also does not work.

1 Like

Are you sure the script is a child of the part?

Thank you it now kills the player on touch!

1 Like

The problem is a missing parent. touch is the leg, for example, Humanoid is a parent of the character not the leg. So it needs to be if touch.Parent:Find......

1 Like