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)
1 | local Part = script.Parent |
2 | Part.Touched:Connect( function (hit) |
3 | local human = hit.Parent:FindFirstChildOfClass( "Humanoid" ) |
4 | if human then |
5 | human.Health = 0 |
6 | Part.CFrame = CFrame.new( 0 , 0 , 15 ) |
7 | end |
8 | end ) |
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)