#Healthbar Help
1 messages · Page 1 of 1 (latest)
** You are now Level 1! **
check when the health of the character changes and just set the bar's size to Health/MaxHealth,0,1,0
could you show a vid of it happening
btw beautiful UI you got there
local HPPercent=math.round(hum.Health/100)
TS:Create(bar, TweenInfo.new(0.05, Enum.EasingStyle.Quad, Enum.EasingStyle.In), {Size=Udim2.fromScale(HPPercent, 1)}):Play()
-- put this inside a while loop or run service
also state the humanoid
sorry for the insanely late reply
here is the script btw:
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChild("Humanoid")
local HealthBar = script.Parent
local function updateHealth()
local size = math.clamp(humanoid.Health / humanoid.MaxHealth, 0, 1)
HealthBar.Size = UDim2.new(size, 0, 1, 0)
script.Parent.Parent.Percentage.Text = tostring(math.floor(size * 100)).."%"
end
updateHealth()
humanoid:GetPropertyChangedSignal("Health"):Connect(updateHealth)
humanoid:GetPropertyChangedSignal("MaxHealth"):Connect(updateHealth)```
got from a tutorial as i have no absolute scripting knowledge
ohhh
easy fix
HealthBar.Size = UDim2.new(size, 0, 1, 0)
here you put size in scale size right?
try to make it start with the size that your bar currently is
convert it to scale if possible
or else it'll be too big
you can also try to wrap the bar inside a container frame and only change the X.Scale part of the size. Make sure the bar’s AnchorPoint is set to (0, 0.5) and its Position to (0, 0.5, 0) so it scales from left to right correctly.
** You are now Level 7! **
SHUT THE FRICK UP
changing the Y to 1
is pretty much telling it to go HUGE for 0 reason
'cause Y = height and X = width
it doesnt update bc it doesnt rlly affect anyways
anything
also maybe just do :Connect(function()
end)
and see what happens
also why maxhealth?
i just do it in a while true loop
or run service
instead of that
uh add some print messages and see what works and what doesn't using simple debugging
yea but he wants to keep it clean probably
so doing a while true loop or stuff like that not only would it not let him do anything else in the same code
but it would look worse
i provided this