#Trying to Multiply xScale by Health Percentage for label of HealthUI. No errors, but nothing changes

1 messages · Page 1 of 1 (latest)

grim moon
#

I hope my scripting makes sense. Attempting to decrease the width of a text label (which is why i multiplied it by percentage). Quite new to this, so any advice would help a lot. Green is the label, and was defined before this section of code. thanks in advance
''''lua
local function onHealthChanged()
local percentage = Health.Value / MaxHealth
local currentSize = Green.Size
Green.Size = UDim2.new((currentSize.X.Scale * percentage), currentSize.X.Offset, currentSize.Y.Scale, currentSize.Y.Offset)
end
''''
Health.Changed:Connect(onHealthChanged)

deft wyvern
grim moon
#

so would it then just be sizeX.scale?

deft wyvern
grim moon
#

im a bit confused

deft wyvern
#

which part

grim moon
#

to resize. like do i use size.X.scale instead of currentSize or is there another function that can be used

deft wyvern
#

set size according to starting size, not current size

#

local startingsize=f.size f.size=startingsize*percent⁩?

#

instead of ⁨f.size=f.size*percent⁩?

#

?

#

#

wdym

grim moon
#

local startingSize = Green.Size
Green.Size = UDim2.new((startingsize.X.Scale * percentage), startingsize.X.Offset, startingsize.Y.Scale, currentSize.Y.Offset)

jagged crescentBOT
#

studio** You are now Level 1! **studio

grim moon
#

is this what you mean? im still confused also tysm for ur help so far

deft wyvern
#

;compile lua ⁨⁨```lua
local percentage=0.67

local GreenSize=67
for i=1,15 do
GreenSize=GreenSizepercentage
end
print("nay ",GreenSize," ~= ",67
percentage)

GreenSize=67
StartSize=67
for i=1,15 do
GreenSize=StartSizepercentage
end
print("yay ",GreenSize," == ",67
percentage)```⁩⁩

modest badgeBOT
#
Program Output
nay 0.16489095875624 ~= 44.89
yay 44.89 == 44.89

grim moon
#

ohhh so make a new variable and dont set them equal

#

this makes so much more sense thank u

grim moon
#

okay ive been trying to implement this into my code but its still not working omfg

#

local currentsize = UDim2.new((StartingSize.X.Scale * percentage), StartingSize.X.Offset, StartingSize.Y.Scale, StartingSize.Y.Offset)
end

#

i tried to use green.size but it just gives "unexpected identifier"