Function to do damage over time

_G.DamageOverTime = function(Humanoid,Dmg,Time,STEP)
 --Step = 0.15
    local t = 0
    repeat wait(STEP)
        t = t + STEP
		local currentDamage = ? -- Insert here
        Humanoid:TakeDamage(currentDamage) -- ?
    until Humanoid == nil or Humanoid.Parent == nil or t >= Time
end

How would I make it so every “STEP” it does a certain amount of damage so that by the time it has reached the given “Time” it has done the full “Dmg”?

3 Likes

Can you tell me what time is equal too?

I also do not think this is the most efficient way in which to do this.

Time will be anything from 1 - 10 probably, and whats a more efficient way to do this?

Sorry - I didn’t read your code properly, disregard what I previously said.

local currentDamage = dmg/(time/step)

I’m pretty sure this will work.

4 Likes