Scaling UI to be the same as another UI that is parented in a different frame

I’m trying to scale a frame to the exact position and scale as another frame. Seems pretty easy other then the fact the target scaled frame is parented inside a different frame and uses scale to determine its position and size. How can I achieve this without having to change the parent of the original frame?

What I want:
image

What occurs:

Code:

local function openAppInterface(App)
	local Interface = MainFrame:FindFirstChild(App.Name)
	
	if Interface then
		Interface.Position = App.Icon.Position
		Interface.Size = App.Icon.Size
		
		Interface.Visible = true
	end
end

Explore

Green = Target position and size
Red = Frame to set scale

1 Like

This is where AbsoluteSize and AbsolutePosition become useful.
Just replace the changes with position and size to absolute position and size.
Be careful though, as it’s read only. (That means we will want to set to Position and not AbsolutePosition, same goes for size)
And remember to use Offset, since it defines the size of the element in pixels.

Interface.Position = UDim2.fromOffset(App.Icon.AbsolutePosition.X, App.Icon.AbsolutePosition.Y) 
Interface.Size = UDim2.fromOffset(App.Icon.AbsoluteSize.X, App.Icon.AbsoluteSize.Y) 
1 Like

Thanks for this, it’s getting somewhere but sadly it decideds to spawn just up of the target position. The scale seems to be fine however.
image

The target position is also located inside a from with a UiGridLayout which could be a factor. I’m not quite sure though but I’d thought I’d mean that as well.

Actually, disregard my previous post. I tried adding the AbsoluteCellSize Y value to the offset and it worked perfectly. Thank you so much for the help.

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