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

Help with kill brick?

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 .

1 answer

✓ Accepted answer

Your code makes no sense at all, try this.

function onTouch(part) 
local human = part.Parent:findFirstChild("Humanoid") 
if (human == nil) then return end -- if it is not a humanoid, then do nothing, otherwise...
human.Health = 0 -- then kill the humanoid
end 
script.Parent.Touched:connect(onTouch)

2 comments

0

Thank you for you're help , and could you give me some tips for making me code as clean as yours and not "making no sense at all " ?

0

Sure, the roblox wiki is very very helpful, always indent and add comments when needed to help you remember what key functions do, Efficiency is key, know when to use local and regular scripts as well as module scripts.

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