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