Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with kill brick?

Asked by 8 years ago

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

Log in to vote
1
Answered by
Voltoxus 248 Moderation Voter
8 years ago

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)

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 " ? KelsiCabana 70 — 8y
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. Voltoxus 248 — 8y
Ad

Answer this question