How do you convert offset into scale?

Hello Devs,

So I have been working on this inventory which consists of a scrolling frame, and I wanted the canvas size to be exactly as how many weapons there are, So I tried scripting that cause I cannot get it that perfect. It did not work as I used scale which in the end makes the tiles become out of place in size. But it would work in offset but it won’t be perfect for all resolutions.

So can someone answer with the formula of converting offset into scale? So that I could set everything into offset when the weapons aren’t loaded, and when they load, I could convert them to scale so they fit all resolutions.

Any help appreciated.

This plugin should help you. I’d also recommend looking into UIAspectRatioConstraints.

Well using ratio you will know that scale being 1 = the whole length so predicting you have a 1920 x1080 display you get this
X: 1:1920
Y: 1:1080
So basically get the y resolution and divide your pixels by itself
Eg

local xreso = 1080
local pixelstoscale = 540
print(1 / (xreso / pixelstoscale))

If I am correct
Output: 0.5

1 Like

Does it have to be the whole resolution? Or can it be the AbsoluteSize of the ScreenGui that can be used as well?

Absolute size should work and be better than player:getmouse() as then it will go along the parents resolution

1 Like