When a part touches a person can the part deal 40 damage on touching the person then remove then put a damage prevenatation it so it doesn't happen again. Because if a character touches it many scripts make it do 40 damage several times. Thanks!
COMMUNITY QUESTION
A damage script?
2 answers
Damage = 40
script.Parent.Touched:connect(function(t)
if t.Parent:FindFirstChild("Humanoid") then
t.Parent.Humanoid.Health = t.Parent.Humanoid.Health - Damage
end
end)
Put in the script.
local Touching = false
Damage = 40
script.Parent.Touched:connect(function(hit)
hum = hit.Parent:FindFirstChild('Humanoid')
if hum ~= nil and not Touching then
Touching = true
hum:takeDamage(Damage)
Touching = false
end
end)
put this Script into the part that's gonna Damage People...
3 comments
0
Just to say, TakeDamage() is Better and Faster... but if u need it to ByPass ForceField Unit then I wouldn't Recommend TakeDamage()
0
I know. That is why I didn't.
0
yup... Also, y cant I comment on people's posts???
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
This doesn't work, it kills on touch
Thanks for the effort though.