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

[UDim2] Problems with keeping X the same?

Asked by 8 years ago

I have this code which was fixed from a previous post. When I flip the brackets, it no longer works properly.

I have a TextLabel in a Frame. Textlabel position is {0,0}{0.5,0} and is draggable. I want to keep the Horizontal position the same (X. This means the GUI always sticks to the left). This script however always keeps it to the top left (Zero) and doesn't allow me to drag the TextLabel downwards.

script.Parent.Changed:connect(function(p)
    script.Parent.Position = UDim2.new(0,script.Parent.Position.Y) --I want the GUI to stick left regardless what changes. Works perfectly the other way round
    --value = (script.Parent.AbsolutePosition.Y - 180)/360
    script.Parent.Parent.Parent.Red.Value = value --These two lines have no relevance to the issue
end)

Many thanks in advance

1 answer

Log in to vote
0
Answered by 8 years ago

I believe UDim2 uses 4 values not 2

"script.Parent.Position = UDim2.new(0,script.Parent.Position.Y)" should prob be "script.Parent.Position = UDim2.new(0,script.Parent.Position.Y,"your value here",your value here")"

Ad

Answer this question