Jump to content

How do I center a GUI?


jkub

Recommended Posts

  • Discord Moderators
  
local x, y = guiGetScreenSize () 
local guiWidth, guiHeight = 500, 400 
  
local centerX, centerY = (x / 2) - (guiWidth / 2), (y / 2) - (guiHeight / 2) 
  

this is pretty elementary lol, you get the half of the screen total width, and subtract it with the half of the guiWidth. If we didn't do the latter, the GUI's top left corner would be the centre instead.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...