Anyway I can convert a position to support an anchor point?

Hey so I’m having trouble with a change in my UI I want to make. I have a script that changes the position around with lots of math and stuff however recently I decided I wanted to change the anchorpoint of the UI to .5,.5 (it was originally 0,0 ). However I don’t want to have to go back and change all the math and stuff just to get the positions right again. Is there anything I can add to a position that would adjust it so that it works with the new anchor point and puts itself in the right position?

Here is an example:
image
Before setting the anchorpoint

After setting the anchorpoint to .5,.5

Is there anyway I can simply do something along the lines of Position + UDim2.new(0.5,0,0.5,0) to readjust the positions? Thanks in advance.

Wait why is there a script to change the location of the ui? What does the script do exactly that you need to do a lot of math?

1 Like

Its the default backpack script in the core gui I just made changes to it. It does math to set the positions. I was just wondering if there was simply something I could add to adjust the position if the anchor point is .5,.5

if it helps this is the code where the position is changed

SlotFrame.Position = UDim2.new(0, centered - (ICON_SIZE / 2) + (sizePlus * factor), 0, ICON_BUFFER)

It involves math and it also uses offset instead of scale which makes it tricky to adjust.
That sets the position properly if the anchorpoint is 0,0. I want to be able to set it to that with the anchorpoint as .5,.5