Idk how to explain but example if a guy loses 10 hp, everytime he loses health his screen gets red how can u do that ?
EDIT: Okay heres the script i've done
local humanoid = game.Players.LocalPlayer.Character.Humanoid local currentHealth = humanoid.Health local Flash = script.Parent.Flash humanoid.HealthChanged:connect(function(health) local change = math.abs(currentHealth - health) Flash.Visible = true wait(0.2) Flash.Visible = false currentHealth = health end)
But when he regenerates health it shows up too! i only want to make it show ONLY when hes losing not getting health.
Use the Humanoid HealthChanged
event. This even fires each time the humanoid's health has changed, with the new health as the argument. You can use this to detect how much damage a humanoid has taken.
local gui = script.Parent.Frame --The gui element local humanoid = game.Players.LocalPlayer.Character.Humanoid local currentHealth = humanoid.Health --Store the previous health before the change. humanoid.HealthChanged:connect(function(health) --Every time the health changes... local change = health - currentHealth --Get the change in health from the stored value. currentHealth = health --Store the new health so we can compare it later. if change <= -10 then --If the humanoid lost more than 10 health... gui.Visible = true wait(.2) gui.Visible = false end end)