Is there a way to get a value before the current health value?
1 Like
You can track the health with a previousHealth variable, use that variable when the health changes, then update that variable to the current health for the next time the health changes.
Here’s an example where you’re tracking a Humanoid’s Health:
local humanoid = -- [The `Humanoid`'s location]
local previousHealth = humanoid.Health
humanoid.HealthChanged:Connect(function(currentHealth)
-- [Use the previousHealth here].
previousHealth = currentHealth -- Update the previous health to the current.
end)
Also, if you have any yielding in your code, put that inside a thread so that you can update the previousHealth variable before the current health value changes again, or else that could be a problem.
1 Like
Thank you you are a genius I couldn’t sleep all day yesterday because of this and it was solved right away!!
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.