so i have a script for my health bar and the script works fine except for the fact that the health appears so small compared to the actual size of the health bar. someone please help me or tell me what i need to do to fix this issue
script:
local player = game.Players.LocalPlayer
local character = player.Character
local healthframe = script.Parent.HealthFrame
local healthbar = healthframe.HealthBar
local staminaframe = script.Parent.StaminaFrame
local staminabar = staminaframe.StaminaBar
while wait() do
if not character:FindFirstChild("Humanoid") then return end
local health = character.Humanoid.Health
local maxHealth = character.Humanoid.MaxHealth
healthbar.Size = UDim2.new(healthframe.Size.X.Scale / maxHealth * health, 0, healthbar.Size.Y.Scale, 0)
end
Add a 0 for your first argument for Udim2.new, and use over Offset over Scale. Also, I think you should remove the 0 at the very end since Udim2.new only accept 4 arguments, but I don’t think it would cause a problem anyways.
okay so it just doesnt show the health bar and shows the background instead. how can i change the order where they show? whenever i try to edit the zindex, it never actually works for me
Are you sure the bar is behind the background ? The bar might just be so small that you can’t see it. (Because depending on which property you’re using, you might just be multiplying by 0…)
So before you change Scale to Offset, it might be useful to know whether you’re using the offset property, or the scale property for your HealthFrame.
If you’re using Scale, you can use your original code, but you will have to replace “healthframe.Size.X.Scale”, by simply “1” (without quotation marks). Simply because your bar is a direct child of the frame. And an width Scale of 1 means it will take the whole width.
The reason why it appeared so small earlier is because you multiplied by the parent’s scale. Which might be 0.25 for example, so it will appear 4 times smaller than it should.
So basically all you have to do is change that line