How to position frame in the corner with a little bit of offset so it's not touching the corner?

,

So as the title says im trying to position a frame into the corner of the screen with a little bit of offset so that it’s not in the exact corner but a little bit away from the corner, but when I try to do this with scale it’s uneven. Here is a picture:


Now as you can see in the picture im setting the position of the frame to {0.9, 0}, {0.9, 0} as to not put the frame into the exact corner but using scale it’s uneven and it’s not offsetting evenly. I have tried using offset to do this and it works just fine on my device, however on a smaller/larger screen than mine it will not work. Here are the pictures:


If anyone could help it would be very helpful. Thanks for reading!

1 Like

You’d have to use a script to dynamically position the frame.

local camera = workspace.CurrentCamera

local function updatePos()
  local vpSize = camera.ViewportSize
  frame.Position = UDim2.fromOffset(vpSize.X - vpSize.X / 10, vpSize.Y - vpSize.Y / 10)
end

camera:GetPropertyChangedSignal('ViewportSize'):Connect(updatePos)

updatePos()

Set the anchor point to the corner. In your case {x = 1, y = 1}
Set the position scale to {x = 1, y = 1} as well, this will place it in the corner.
Use the position offset to set the desired offset amount.
So your position will end up with something like {1, -5, 1, -5}, for example.

1 Like

Yes using offset allows me to move it evenly however it will not scale for smaller/larger devices.

Is there any way to do this without code or is that the only way?

I’m 95% sure using a script is the only way to do it.
There’s plenty of UI modifiers but none of them can achieve the effect you need.

Most developers would set the anchor point to (1, 1) and then set the position mixing up the offset and the scale but I’m pretty sure only script will allow you to achieve the perfect outcome.

1 Like

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