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

How to make this persistent damage?

Asked by 10 years ago

What I am asking, is if every two seconds you're standing on this, it takes away 10 health.

2 Seconds = 10 damage

function onTouched(hit)
    local humanoid = hit.Parent:findFirstChild("Humanoid")
    if (humanoid ~= nil) then
        humanoid.Health = humanoid.Health - 10
    end
end

script.Parent.Touched:connect(onTouched)
0
I'd recommend adding debounce and setting it to two seconds. 2eggnog 981 — 10y
0
That'd work? TheRings0fSaturn 28 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

if (humanoid ~= nil) then while true do humanoid.Health = humanoid.Health - 2 wait(2) end

If you want to stop at a certain point then do the for i = 1,5

Ad

Answer this question