Ad
Log in to vote
0

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

Asked by 9 days ago
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)

2 answers

Log in to vote
0
Answered by
eLunate 5136 Trusted Moderation Voter Community Moderator
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
View all comments (3 more)
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
Ad
Log in to vote
0
Answered by
MattVSNNL 116
9 days ago

Try using this amazing plugin called autoscale

https://web.roblox.com/library/1496745047/AutoScale-Lite

Answer this question