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

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

Asked by
TomsGames 225 Moderation Voter
4 years ago

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

Log in to vote
3
Answered by
Benbebop 1049 Moderation Voter
4 years ago
Edited 4 years ago

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.

0
Oh - thanks so much! Such a simple explanation :) TomsGames 225 — 4y
Ad

Answer this question