Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't the Part reduce my health to 0 when I touch it?

Part = script.Parent Part.Touched:Connect(function(hit) if hit.Parent == hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Health = 0 end Part.CFrame = CFrame.new(0, 0, 15) end)

2 answers

✓ Accepted answer
local Part = script.Parent
Part.Touched:Connect(function(hit)
	local human = hit.Parent:FindFirstChildOfClass("Humanoid") 
	if human then
		human.Health = 0
		Part.CFrame = CFrame.new(0, 0, 15)
	end
end)

1 comment

0

Thanks

try this... local Part = script.Parent

local function onPartTouch(otherPart) local partParent = otherPart.Parent local humanoid = partParent:FindFirstChildWhichIsA("Humanoid") if humanoid then humanoid.Health = 0 end end Part.Touched:Connect(onPartTouch)

This discussion is preserved as it was. New answers, comments, and votes are closed.