Ui positioning does not work

,
...
local targetAbsolutePosition = Obj.AbsolutePosition
local ToNewPos = TS:Create(frame, 
		TweenInfo.new(1.3, Enum.EasingStyle.Sine), 
		{Position = UDim2.fromOffset(targetAbsolutePosition.X, targetAbsolutePosition.Y)})
	ToNewPos:Play()
...

Above is a code snippet from my module script which tweens a frame “frame” to the position of “obj’s” absolute position.

NOTE: obj position is controlled by a ui list layout.

however when running this code. the frame not only isnt positioned to it. It goes to the full other side of the screen. (top in this case) which makes absolutely no sense. can someone explain what im doing wrong?

1 Like

when just assigning the position of the frame and not tweening it it does the same so its not a tweening issue

1 Like

Hey!

It looks like the issue you are having is coming from the way AbsolutePosition and UDim2.Position work. AbsolutePosition gives the exact pixel position on the screen, while UDim2.Position is relative to the parent UI element.

Instead of using AbsolutePosition directly, you need to subtract the parent UI’s AbsolutePosition to get the correct relative position. Look the code example I wrote bellow.

local guiParent = frame.Parent
local relativePosition = Obj.AbsolutePosition - guiParent.AbsolutePosition

local ToNewPos = TS:Create(frame, 
    TweenInfo.new(1.3, Enum.EasingStyle.Sine), 
    {Position = UDim2.fromOffset(relativePosition.X, relativePosition.Y)})
ToNewPos:Play()

This should ensure that the frame moves correctly within it’s parent. Let me know if you need further help.

-DiscMil

2 Likes

the frame however has no parent other then the screen gui its self. so this may probably not work. sorry if i didnt clear that up.

1 Like

after debugging more the obj absolute position is seeming to be COMPLETELY off,

  10:42:39.980  {0, 1244}, {0, 722}  -  Client - around the correct positioning
  10:42:40.787  703.754761, 4.21811676  -  Client - what its telling me the correct position is

Hmm, what’s the size of your target obj? AbsolutePosition is always the Top Left corner of the gui object, no matter where you have the anchor or anything else set.

2 Likes


the white square is the “frame”


this is where i want the frame to be positioned.

1 Like

could this just be a bug?

1 Like

so the absolute position of Obj is inaccurate? what is Obj?

2 Likes

a frame inside a ui layout.

1 Like

What does absolute position even mean in Roblox? I know in HTML the absolute positioning ignores all other objects.

Is there a way to maybe not use that? Just the .Position would work, right?

1 Like

when a ui is parented to an object whcih is also a child to an enabled uilayout THEN its position is overridden with the layout becoming inaccurate and really only readable. absolute position gives the ui offset of the exact position of the ui (somewhat)

1 Like

Thank you fir the information! What I can say, I would do something to exclude this layout or something, but I don’t have any actual idea how to do that.

I hope you’re gonna find the solution soon!

1 Like

must have gotten your lcuk cause i just did. no clue how it solved tho. today it just worked soo im happy.

1 Like