whats a good calculation for making the health always be the same percentage of max health when max health is changed?
u can obtain the %age simply by
local HealthPercent = Hum.Health/Hum.MaxHealth * 100
It’s tough to say without a better description.
If you change the percentage 25% it will calculate when dealing with either 100 health or 150 health, you just get different results.
Do you want to have each increment increase/decrease the same amount each change in health (for example, each damage attack)?
Or do you want it to be the same percentage each damage attack?
Or do you mean if a player has 50 out of 100 health but when they get a power up where the health is now 150 they still have 50/150?
if the player were to have some sort of power up that increased their max hp. if they had 50/100 hp then the hp would increase to the same percentage of hp (50%) and if the max hp were to decrease then it would decrease to the same percent
this worked for when the health went down but not for when the health goes up, do you know a way to make it do it when it goes up?
by putting it in an HealthChanged Event, Im sure it will work. Can i see ur code which u are using currently to do it
right now i have a tool and when you equip the tool your max hp increases and then when you unequip the tool the max hp increases, it almost works its just the issue is when you spam equip the tool it starts increasing your hp very slowly
tool.Equipped:Connect(function()
local HealthPercent = character.Humanoid.Health/character.Humanoid.MaxHealth * 100
character.Humanoid.MaxHealth = character.Humanoid.MaxHealth + 100
character.Humanoid.Health = character.Humanoid.Health + 100
tool.Unequipped:Connect(function()
local HealthPercent = character.Humanoid.Health/character.Humanoid.MaxHealth * 100
character.Humanoid.MaxHealth = character.Humanoid.MaxHealth - 100
character.Humanoid.Health = HealthPercent
end)
i changed the image so its a lil easier to understand, sry about that
u should calculate the hp percent after additions and subtractions of Health ig
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.