Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why am I not able to save a UDim2 value in this dictionary?

Am I missing something obvious? Here is my code:

local hidGoal = {}
hidGoal.Position = UDim2.new({0.65, 0},{-0.2, 0})
print(hidGoal.Position)
print("Printed hidgoal position")

Output:

  {0, 0}, {0, 0}
  Printed hidgoal position

Why does this allow me to set a UDim2 position, but only as {0, 0}, {0, 0}? I cannot make sense of it.

1 answer

✓ Accepted answer

When using UDim2.new or really any .new you do not include anything but numbers and commas. Since you have curly brackets in the parameters its likely confusing the numbers for string values. To fix this write it exactly as you have just remove the curly brackets.

Ex.

UDim2.new(0.65, 0, -0.2, 0)

UDim2.new is just usually presented with curly brackets to make what each parameter is clearer.

1 comment

0

Oh - thanks so much! Such a simple explanation :)

This discussion is preserved as it was. New answers, comments, and votes are closed.