Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Can I Make this HealthBar Scaling work more versatile?

Asked by 7 years ago

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

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

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!

0
How did I forget I could do that... thanks for telling me or else this would've taken me days lmao laughablehaha 494 — 7y
0
no problem.. remember to always use the Wiki, it is a good source to know more about objects in ROBLOX. starlebVerse 685 — 7y
Ad

Answer this question