Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Does UDim2 correctly take UDim constructors?

Asked by 7 years ago

Hey I was trying to move a GUI using UDim2.

I put this command in my code to test how UDim2 works:

print(UDim2.new(UDim.new(1,0), UDim.new(0,0)))

It outputs

{0, 0}, {0, 0}

Is this supposed to happen? The Roblox Wiki says it should work.

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

And the Roblox Wiki is correct, it does work.


You can construct a UDim2 3 different ways.

  • UDim2.new() : Creates a new UDim2, with all values set to 0.

  • UDim2.new(xScale, xOffset, yScale, yOffset) : Creates a new UDim2 with the given values.

  • UDim2.new([UDim] xDim, [UDim] yDim) : Creates a new UDim2 from the given UDim values.


The second constructor listed is the most commonly used method, but the third listed will work. I'm not sure how you got your results from attempting to print out the UDim2.

0
Can you stop downvoting everything i post? Gees.. RubenKan 3615 — 7y
0
your answer contained 30% of the information, its not a good answer RubenKan 3615 — 7y
0
your answer contained 30% of the information, its not a good answer RubenKan 3615 — 7y
View all comments (2 more)
0
Perhaps it's because I am using a version of Roblox from 2 years ago. randomsmileyface 375 — 7y
0
Perhaps. Goulstem 8144 — 7y
Ad

Answer this question