Jump to content

How do I center a GUI?


jkub

Recommended Posts

Posted

Lets say I make a GUI window for a script. I don't know exactly how to center that GUI in the exact center of my screen, no matter the resolution. Can someone help me please :)

  • Discord Moderators
Posted
  
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.

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...