Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

7 comments

0

What do I have to change? Sorry, I'm very confnused.

0

The 1 on line 9

0

I tried changing it, it only made the height of the healthbar higher.

0

Okay wait, is it supposed to be 'Ahealth,0,1' If so it made my healthbar completely invisible

0

Please review the documentation for fromScale https://developer.roblox.com/en-us/api-reference/datatype/UDim2

0

I still don't get it.. sorry

0

Then you have derived this script by modifying scripts you don't understand and I can't help you.

This discussion is preserved as it was. New answers, comments, and votes are closed.