function onTouch(Part)
Part.Parent:TakeDamage(4)
end
script.Parent.Touched:connect(onDamage)
COMMUNITY QUESTION
how do I make someones humanoid take damage when they touch a part named "SmokeE"?
2 answers
Need more information. This is a simple script which searches for a Humanoid and then gives damage(with debounce).
local touched = false
script.Parent.Touched:connect(function(part)
if not touched then
touched = true
local humanoid = part.Parent:findFirstChild('Humanoid')
if humanoid then
humanoid:TakeDamage(4)
end
touched = false
end
end)
You messed up a bit by having the function named "onTouch" and having the .Touched:connect(onDamage). To fix this all you have to do is this:
function onTouch(Part)
Part.Parent:TakeDamage(4)
end
script.Parent.Touched:connect(onTouch)
That should fix your script.
This discussion is preserved as it was. New answers, comments, and votes are closed.
