#HealthBar Issue
1 messages · Page 1 of 1 (latest)
local Frame = script.Parent
local Text = Frame.Parent.HealthTextFrame.TextLabel
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
local HealtPercent = Humanoid.Health / Humanoid.MaxHealth
Frame.Size = UDim2.new(HealtPercent,0, 0, 0)
Text.Text = tostring(math.floor(Humanoid.Health))
end)
Since you set the frame.Size to like 100, 0, 0, 0 you won't able to see it.
what should i do?
Istead of Frame.Size = Udim2.new(HealtPercent,0,0,0) do Frame.Size = Udim2.new(HealtPercent,0,1,0) where 1 is the height of the bar
do somethings like this
Frame.Size = UDim2.new(health, 0, Frame.Size.Y.Scale, Frame.Size.Y.Offset)
try
i tried that and it made it too big
Too big horizontally or the height?
both
now it has 1 problem left
** You are now Level 6! **
Then it must be how the bar is made -_- , if it is scaled and it doesnt occupy the whole frame then do this :
Frame.Size = Udim2.new(HealtPercent,0,1,0)
ok let me fix
Yea, like GabiL said, its a isseus with how you made the frame then
Try using a math.clamp thing
How is your frame build?
HealthPercent = math.clamp(Humanoid.Health / Humanoid.MaxHealth)
it has constraint and UIcorner
Delete constraint
Or else it aint goint to work
Delete the constraint
Do you have somethings like this:
-
Screengui
-
Frame
-
Healthbar (frame)
Or its it like -
Screengui
-
Healthbar (Frame)
second
a
Add frame, put health bar in it 🙏
k