Is there a script to center a GUI no matter what resolution a PC has? I've been looking for one, i've even attempted to make a script but sadly my scripting skill level stinks. ( I'm currently learning how to script on the ROBLOX wiki )
✓ ANSWER ACCEPTED
Co-ordinates to center a GUI?
2 answers
✓ Accepted answer
Inside a LocalScript in the PlayerGui or Backpack
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local Xcenter, Ycenter = (mouse.ViewSizeX / 2), (mouse.ViewSizeY / 2)
print(Xcenter, Ycenter)
If you want to position the Gui in the center here the code:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local screenGui = script.Parent
local Frame = screenGui.Frame
local XcenterFrame, YcenterFrame = (Frame.Size.Offset.X / 2), (Frame.Size.Offset.Y / 2)
local Xcenter, Ycenter = (mouse.ViewSizeX / 2), (mouse.ViewSizeY / 2)
local finalXPos, finalYPos = (Xcenter - XcenterFrame), (Ycenter - YcenterFrame)
Frame.Position = UDim2.new(0, finalXPos, 0, finalYPos)
Just use the Scale part of a UDim2.
And make the position:
gui.Position=UDim2.new(.5-gui.Size.X.Scale/2,0,.5-gui.Size.Y.Scale/2,0)
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Thx for the help! :D
p = screenGui p.Position = UDim2.new(0.5,-p.AbsoluteSize.X/2,0.5,-p.AbsoluteSize.Y/2)
You're welcome !