0

# How do I scale a UI in both X axis and Y Axis?

Edited 9 days ago

Hi, I have been trying to figure out what's causing why it only scales on the X axis, but not both, there are no errors in the output too.

I am trying to make a healthbar that is shaped as a sphere.

Here is the script.

local healthbarr = script.Parent
local Player = game:GetService("Players").LocalPlayer

local Char = Player.Character or Player.CharacterAdded:Wait()
local huma = Char:WaitForChild("Humanoid")

local function health()
local Ahealth = math.clamp(huma.Health / huma.MaxHealth, 0, 1)
healthbarr.Size = UDim2.fromScale(Ahealth, 1)
end

health()

huma:GetPropertyChangedSignal("Health"):Connect(health)

huma:GetPropertyChangedSignal("MaxHealth"):Connect(health)



0
eLunate 5136
9 days ago

Look on line 9 - You're only scaling Ahealth on the X axis, with a constant 1 on the Y axis. You should be able to work the rest out.

0
What do I have to change? Sorry, I'm very confnused. canadagamer1223 0 — 9d
0
The 1 on line 9 Trongaming3211 7 — 9d
0
I tried changing it, it only made the height of the healthbar higher. canadagamer1223 0 — 9d
0
Okay wait, is it supposed to be 'Ahealth,0,1' If so it made my healthbar completely invisible canadagamer1223 0 — 9d
0
Please review the documentation for fromScale https://developer.roblox.com/en-us/api-reference/datatype/UDim2 eLunate 5136 — 9d
0
I still don't get it.. sorry canadagamer1223 0 — 9d
0
Then you have derived this script by modifying scripts you don't understand and I can't help you. eLunate 5136 — 9d