Moving a Frame to another frame without reparenting

So my code needs to move a frame to the same position as another frame without reparenting.

The reason why reparenting won’t work is because you’ll be able to drag the frame off of the parents and sometimes the parent frames have clip descendants and obviously won’t show the dragged frame.

The code I’m using in a test place is exactly this

local Frame = script.Parent:FindFirstChild("Frame1", true) -- White frame
local Frame2 = script.Parent:FindFirstChild("Frame2", true) -- Red frame

Frame2.Position = UDim2.fromOffset(
	Frame.AbsolutePosition.X - Frame2.Parent.AbsolutePosition.X,
	Frame.AbsolutePosition.Y - Frame2.Parent.AbsolutePosition.Y
)

The results I want should look like

The results I am getting looks like

It’s not perfectly aligned like the first one and has a small offset which can be problematic.

I fixed the issue myself and on the rare occasion that someone else finds this niche issue with their game, offset does not work with decimals and you need to convert the position into scale to align it properly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.