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

Is there a way i can prevent this script from damaging the same humanoid twice?

Asked by
Echtic 128
5 years ago

So i want to prevent this script from damaging the same humanoid twice while still being able to damage other ones, just not multiple times.

wait()

script.Parent.Touched:Connect(function(hit)

    local h = hit.Parent:FindFirstChild("Humanoid")

    local dmg = 15

    if h~=nil then


        h:TakeDamage(dmg)



        end



end)

1 answer

Log in to vote
1
Answered by 5 years ago

You should store the names of the players/npcs in a table, if you want to hurt them once, even after they reset, or, if you want to reset this when the humanoid dies, you can store an object in the humanoid when you damage it and then check its presence each time.

Ad

Answer this question