I am using a debugger and (i-1)*50 is equal to 50, but UDim2.new(s.Position.Width, s.Position.X, s.Position.Height, (i-1) * 50) is equal to {0, 0}, {0, 0}.

This makes no sense.

Here is the code:

local SoundButtonTemplate = script.Parent.Sound:Clone() -- This is a Frame, not a Sound.
    for i, sound in soundArray do
        local s = SoundButtonTemplate:Clone()
        s.GamepassId.Value = sound["GamePassId"]
        s.Text = sound["Details"].." (ID: "..sound["SoundId"]..")"
        s.Parent = script.Parent
        s.Position = UDim2.new(s.Position.Width, s.Position.X, s.Position.Height, (i-1) * 50)
  • \$\begingroup\$ Interesting. So you say that if you create a new local variable, assign (i-1) * 50 to it and then pass that variable as the 4th parameter to UDim2.new then the code behaves differently? \$\endgroup\$
    – Philipp
    Commented Sep 8, 2023 at 12:13
  • \$\begingroup\$ @Philipp I have checked and even if I put the modified value in a variable and then use the variable as the 4th parameter it still returns 0 regardless of the variable. \$\endgroup\$
    – ridiche34
    Commented Sep 8, 2023 at 19:46


You must log in to answer this question.

Browse other questions tagged .