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

A damage script?

Asked by
Mystdar 352 Moderation Voter
10 years ago

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!

2 answers

Log in to vote
0
Answered by
KAAK82 16
10 years ago
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...

0
Just to say, TakeDamage() is Better and Faster... but if u need it to ByPass ForceField Unit then I wouldn't Recommend TakeDamage() KAAK82 16 — 10y
0
I know. That is why I didn't. fireboltofdeath 635 — 9y
0
yup... Also, y cant I comment on people's posts??? KAAK82 16 — 9y
Ad
Log in to vote
0
Answered by 10 years ago
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.

0
This doesn't work, it kills on touch Mystdar 352 — 10y
0
Thanks for the effort though. Mystdar 352 — 10y

Answer this question