Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How Can I Make this HealthBar Scaling work more versatile?

By versatile in exact terms, I mean if a character's maxhealth was more or less than 100, how can I size my Health Bar?

while wait() and plr.Character do
	script.Parent.Size = UDim2.new(plr.Character.Humanoid.Health/100,0,1,0)
end

This script works at any MaxHealth, but the size of the GUI either larger or smaller depending on its max health. I want the overall size of the GUI to stay the same whether or not the max health changes. How can I go about doing this?

1 answer

✓ Accepted answer

There is a property named "MaxHealth" in the Humanoid. It is the Player's maximum amount of health. This will be what you need. Let me show you the script.

while wait() and plr.Character do
    script.Parent.Size = UDim2.new(plr.Character.Humanoid.Health/plr.Character.Humanoid.MaxHealth,0,1,0)
end

Any questions? Please leave a comment below. Thanks and I hope this will help!

2 comments

0

How did I forget I could do that... thanks for telling me or else this would've taken me days lmao

0

no problem.. remember to always use the Wiki, it is a good source to know more about objects in ROBLOX.

This discussion is preserved as it was. New answers, comments, and votes are closed.