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

[UDim2] Problems with keeping X the same?

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

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")"

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