How can I compare UDim values?

Hi devs,

I’m wanting to know if there’s a way to compare UDim values.
Is there a way to do this?

1 Like

You cant unless you break the udim2 and compare them seperately.

1 Like
print(UDim.new(0, 0) == UDim.new(0, 0)) --true
print(UDim.new(0, 0) == UDim.new(math.pi, math.pi)) --false

‘UDim’ values (objects) are treated as first class values so Luau’s comparison operations apply.

3 Likes

Do you know if there’s a way to split the x and y?
I’ve tried using .X and .Y but it gave an error.

UDim doesn’t have X or Y. It is Scale & Offset.
UDim2 has X and Y with Scale & Offset.

UDim:

  • Scale
  • Offset

UDim2:

  • X
    • Scale
    • Offset
  • Y
    • Scale
    • Offset
1 Like