function ontouched (hit)
Local h= findfirstchild = (humanoid)
If h~=nill then
Humanoid health = 0
End
End
script.parent.touched:connect (ontouched)
COMMUNITY QUESTION
Is this right for a killbrick script?
2 answers
Good try. I admire your effort, but here are some tips.
You should set up your function like this if you are only going to use the function once in your script. For cleaner and more compacted coding:
script.Parent.Touched:connect(function(Part)
end)
Coding in every language is case sensitive. So be aware of that, in ROBLOX Studio it should underline the syntax errors you have. In this case local, if and end needs to be all lowercase. To define h and check for h, it's more efficient to just put if h then. if not Part.Parent then return end is for safety measures.
script.Parent.Touched:connect(function(Part)
if not Part.Parent then return end
local h = Part.Parent:FindFirstChild('Humanoid')
if not h then return end
h.Health = 0
end)
function onTouched(Obj) local h = Obj.Parent:FindFirstChild("Humanoid") if h then h.Health = 0 end end
script.Parent.Touched:Connect(onTouched)
This discussion is preserved as it was. New answers, comments, and votes are closed.
