Middle of ScrollingFrame?

Quick question -
But if I were to get the centre of a scrolling frame, X & Y meeting point - How would I go about doing this?
I’m new to working with UI scales etc and noticed that AbsoluteSize and normal size don’t work when trying to get the centre.

1 Like

Set the anchor point of the object to 0.5, 0.5, then set the position to UDim2.new(0.5, 0, 0.5, 0. This will make the object the center of any other element.

1 Like

c6e9b510bf6a41799f3b6188db8c3dc4

How can I use that to work out the core centre as the CanvasPosition?

Use the AbsoluteWindowSize property and divide it by 2.

That’s what I don’t understand tho -
image

This is the AbsoluteWindowSize -
The CanvasPosition is at it’s MAX. So how could I work that?

Multiply the AbsoluteWindowSize by the scale in the x and y axis, then divide it by 2:

local MidX = AbsoluteWindowSize.X * XScale -- Getting the total X
local MidY = AbsoluteWindowSize.Y * YScale -- Getting the total Y

local Middle = UDim2.fromOffset(MidX / 2, MidY / 2) -- Dividing by 2 to get the middle
2 Likes

This was a nice way of working out the middle; but how do I convert this into a Vector2 to set the Position?

Just get the X and Y offset of Middle:

Vector2.new(Middle.X.Offset, Midle.Y.Offset)

Values don’t match :confused: When the ScrollingFrame is at it’s max the CanvasPosition is:
2837, 1637 so the middle CanvasPosition will be: 1418.5, 818.5.

Using the method above, the v2 returned is: 331, 181

The reason I can’t have set numbers though is that the ScrollingFrame won’t always be the same size.

ScreenGui.Content.CanvasPosition = Vector2.new(9999 * 9999, 9999 * 9999)
local PosX = ScreenGui.Content.CanvasPosition.X / 2
local PosY = ScreenGui.Content.CanvasPosition.Y / 2
ScreenGui.Content.CanvasPosition = Vector2.new(PosX, PosY)

Found a work around, force the MaxPosition then work backwards.