How to convert Absolute Position to Scale?

I never code UIs, but I’ve searched on the Dev Forum and other places, tried some things, but without success. Who could help me?

function convertAbsoluteToScale(guiObject: GuiObject)
	local absolutePosition = guiObject.AbsolutePosition
	local parentAbsolutePosition = guiObject.Parent.AbsolutePosition
	
	local scaleX, scaleY = (absolutePosition.X / parentAbsolutePosition.X), (absolutePosition.Y / parentAbsolutePosition.Y)
	
	return UDim2.fromScale(scaleX, scaleY)
end

because i try get position in list layout but i failed …
i can only get absolute position

So you need to take zero = child.AbsolutePosition - parent.AbsolutePosition (acts like parent is at 0, 0 even when it’s not.)

Now that we have zero we simply do a

scale = zero / parent.AbsoluteSize

You could just divide the two related properties, which are parent.AbsoluteSize and target.AbsoluteSize.

Then, you can just divide them like:

local scale = target.AbsoluteSize/parent.AbsoluteSize

I may have misread the title as “size”.

To get the scalar position, you could get the three related properties, which are parent.AbsolutePosition, parent.AbsoluteSize and target.AbsolutePosition.

local scale:Vector2 = parent.AbsoluteSize/(target.AbsolutePosition+parent.AbsolutePosition)