Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years 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 3 years 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 — 3y
0
The 1 on line 9 Trongaming3211 7 — 3y
0
I tried changing it, it only made the height of the healthbar higher. canadagamer1223 0 — 3y
0
Okay wait, is it supposed to be 'Ahealth,0,1' If so it made my healthbar completely invisible canadagamer1223 0 — 3y
View all comments (3 more)
0
Please review the documentation for fromScale https://developer.roblox.com/en-us/api-reference/datatype/UDim2 User#6546 35 — 3y
0
I still don't get it.. sorry canadagamer1223 0 — 3y
0
Then you have derived this script by modifying scripts you don't understand and I can't help you. User#6546 35 — 3y
Ad
Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
3 years ago

Try using this amazing plugin called autoscale

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

Answer this question