How to change the ui size?

  1. What do you want to achieve? Keep it simple and clear!
    I am tryin to change my hpBar size.
  2. What is the issue? Include screenshots / videos if possible!
    When u try to do this it set’s every number of the size to 0
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i can’t seem to find anything that can help me on the devforum

this is my code

hpBarEvent.OnClientEvent:Connect(function(damage)
	health -= damage
	print(damage)
	hpBar.Text = health.."hp / 400 hp"
	hpBar.Size = UDim2.new(0, 370, 0, 25)
end)
2 Likes

Could we see more of the code? Is there another script setting this size?

Also Typically, HP Bars are designed with a backing frame, and the actual HP Bar frame on top. Use Scale instead of offset.

local XFormula = (health / maxHealth)
hpBar.Size = UDim2.new(XFormula, 0, 1, 0)
1 Like

Sorry for the late responce but here is the full script. And no there is no other script inpacting the size of the bar.

Also, my hpBar is just like you said whit a backing frame

local hpBarEvent = game.ReplicatedStorage:WaitForChild("hpBar")
local hpBar = script.Parent:WaitForChild("HPbar")
local health = 400

hpBarEvent.OnClientEvent:Connect(function(damage)
	health -= damage
	print(damage)
	hpBar.Text = health.."hp / 400 hp"
	hpBar.Size = UDim2.new(0, 370, 0, 25)
end)

I don’t know why but i changed nothing and it now works.