When will I ever use UDim?

So I have a small question about the usage of UDim when it comes to Gui, I have never used UDim when positioning or sizing Gui, and I was wondering about how useful it is for Gui, like this for example, what would be different between the two?

UDim2.new(UDim.new(1, 0), UDim.new(1, 0)) -- Creates UDim2 out of 2 UDim's

UDim2.new(UDim.new(1, 0), 1, 0) -- Creates UDim2 out of UDim's and Number Value's

UDim2.new(1, 0, 1, 0) -- Regular Number Values

And Besides that, is there really any other use for it? Is that all it would be used for?
And Should I be using it at all?

2 Likes

In practice? You’re constantly using it. UDim2 basically consists of a pair of UDim, as you’ve pointed out yourself. Whenever you access UDim2.X or UDim2.Y, you’re accessing UDim type. Will you be using the constructor? I doubt it. I don’t. Especially since we can also use UDim2.fromScale and UDim2.fromOffset. So this essentially creates two new UDims too.

1 Like

Yeah I already know that, I was asking about the usage when making a UDim2 like the code provided.

1 Like

Internally, the code doesn’t really care whether you send raw numbers or a UDim.

I just remembered an instance of UDim.new() actually being used as a standalone type, and that’s in UICorner, but it’s seldom used in scripts.

1 Like

Never knew thats how Udim.new was used, I was always using regular number values for my Udim2’s

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.