What is the best way to put a Gui / Ui in the center of the game?

Hello users, this time I have a problem with Guis / Uis, I would like to put a frame in the center of the game however I am not seeing what is the best way to do this, what is the best way to do this?

You can use Scale instead of Offset.

Offset is position measured in pixels, for example {200,400} (more exactly UDim2.new(0, 200, 0, 400))
Scale is position measured relative to a percentage, for example {0.5, 1} is going 50% to the right, 100% up (more exactly UDim2.new(0.5, 0, 0.5, 0))

Technically to get the UI in the middle, you have to do {0.5, 0.5}, which is technically the middle. Also to make it be centered for all screens no matter what, you can use set the AnchorPoint property to Vector2.new(0.5, 0.5) as well, which will make the origin of the UI be its center.

local ui = --wherever it is

ui.AnchorPoint = Vector2.new(0.5, 0.5)
ui.Position = UDim2.new(0.5, 0, 0.5, 0)
4 Likes