Exactly what the title says, I am confused on how to do this, I am trying to multiply my offset size by 4 but nothing seem to work.
Thanks in advance, have a nice day.
1 Like
local new = UDim2.new(old.X.Scale, old.X.Offset * 4, old.Y.Scale, old.Y.Offset * 4)
“old” is a reference to the old udim2 that you want to multiply by 4
6 Likes
or you could do this
using offset
UDim2.fromOffset(old.X.Offset * 4, old.Y.Offset * 4)
using scale
UDim2.fromScale(old.X.Scale * 4, old.Y.Scale * 4)
4 Likes
Thank you both for the help have a great day
1 Like
What if both scale & offset is being used?
1 Like
you shouldn’t be using both of them, I consider that bad practice
1 Like
I agree & you can always add the other component to the UDim2 value created through fromOffset/fromScale by creating a new one using the standard .new() constructor anyway (and borrow some of the values from the previous one).
1 Like
Probably doesn’t suit this operation but use matrices multiplication
UDim2.X.Scale * number
UDim2.X.Offset * number
UDim2.Y.Scale * number
UDim2.Y.Offset * number
assuming the parent size is (250, 50)…
(0.5, 50, 0.2, 10) * 4 → (2, 200, 0,8, 40)
or (175, 20) * 4 → (600, 80)
4 Likes