Keeping it simple and clear. How would I make the HealthChangedEvent not fire if the player is regenerating health? Example: Player lost 10 health HealthChanged Detected it but it doesn’t detect the health changing when the player is regenerating as this is for my blood system I am making. Output Reading: 10 (this prints because i added an system where it detects how much health points you lost) however when i regenerate the system detects it Output Example: 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1 - 0.
I don’t want it to do that.
Any response relating to this topic would be appreciated as I need an direct answer since I won’t be able to make my blood system with this problem.
You could log the previous health as a variable in your code, then when the health changes, detect if the previous health was bigger then current health, which means you lost health.
If you don’t want Health Regeneration then make a server script in StarterCharacterScripts and name it “Health”, nothing should be inside the Script, however.
I want health regeneration in my game and therefore I don’t want HealthChanged to detect it as the variable I made didn’t work. You can check up above.
Does it use the default regeneration script or one that was made by you? If you use the default one, I suggest checking the increment and check if the last health was smaller than the new health by the increment value.
I’m using the default one however I’m gonna make it round the humanoid health and make regeneration faster so just slight modifications and not an custom one.
You can make a custom health. For example, it doesn’t do damage to the Humanoid’s health, instead, it decreases a NumberValue inside the charactermodel or Humanoid. Use a script to getpropertychangedsignal for the value of the numbervalue. If it changed then use the script to make it regenerate at the rate you want. If the numbervalue falls to 0, then the player dies. If you do this, your damage script won’t be using Humanoid:TakeDamage() or Humanoid.Health, it will be PathToNumberValue.Value = Damage .
Is this what you want? To change the regeneration rate? I haven’t try it, but I think you can make a copy of this script, change the rate, then when the player joins, destroy the original one and clone the custom one into the charactermodel.
I’m asking for HealthChanged not to detect the default regeneration or an custom one. As this is for a blood system perse. I already know how to change the regeneration rate and stuff. As the other solution I tried didn’t work check up above to the first reply if you would like to. Example: When i take 10 damage it prints 10 but when I Regenerate it prints 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1. I don’t want it to do that.
If I am correct, you only want to detect health loss.
You can have a variable which contains whatever previous health was and check on health changed that if the new health value is greater or lower.
local Humanoid = script.Parent -- Humanoid
-- Keep a check of whateve the health has updated to
local PreviousHealth = Humanoid.Health
Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
-- If health increased, set the previous health to the new one and return
if Humanoid.Health > PreviousHealth then PreviousHealth = Humanoid.Health return end
-- If the above if statement didn't pass, that means health has been decreased
-- Set previous health to new health
PreviousHealth = Humanoid.Health
print(Humanoid.MaxHealth-Humanoid.Health) -- How much health humanoid has lost
end)