hamburger="hummanoid" myFunction = "part" script.Parent.Touched:connect(function(hamburger) if hamburger.Parent.FindFirstChild.myFunction then hamburger.parent.Head:Destroy() end end)
-- This script destroys player head --Its really wrong --Please help me fix it .
Your code makes no sense at all, try this.
1 | function onTouch(part) |
2 | local human = part.Parent:findFirstChild( "Humanoid" ) |
3 | if (human = = nil ) then return end -- if it is not a humanoid, then do nothing, otherwise... |
4 | human.Health = 0 -- then kill the humanoid |
5 | end |
6 | script.Parent.Touched:connect(onTouch) |