...
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?
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.
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.
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)
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.