Maths problem involving a for loop

The amount of damage dealt to a player is picked randomly. However, when tweening the health bar, it always takes 0.5 seconds. So if a lot of damage is dealt, the health bar moves quicker, while if a small amount of damage is done, it moves slower.
I want the numbers representing the player health to also emulate this through a for loop, for example:

	for health = CurrentHealth, NewHealth, -1 do
		HealthBar.Text = health
		
		task.wait(Time)
	end

The problem is, how would I calculate for task.wait(Time), so that the loop will always be finished by 0.5 seconds?

You could try this to get the step for the task.wait

local step = 0.5 / math.abs(CurrentHealth - NewHealth)

Let’s say CurrentHealth is 50 and NewHealth is 55, you’d have -5, which math.abs turns into 5 and then uses that to divide onto 0.5, giving 0.1

It should be task.wait(0.5) / math.abs(CurrentHealth - NewHealth).