generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: What position for a gui so that it is in the middle of the screen?

Previous Thread :: Next Thread 
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 08:49 PM
Title says all.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
24 Mar 2012 08:55 PM
It's always:

For Scale:
.5 - (GuiY/XSize/2)

Or:
ScreenGui.AbsoluteSizeX/Y - (GuiY/XSize/2)
Report Abuse
RabbitRobot is not online. RabbitRobot
Joined: 09 Apr 2011
Total Posts: 173
24 Mar 2012 08:56 PM
Well, I usually put it 650 X Offset

It should hit the middle, if not just fiddle with it xD

Hope you get it soon!
Report Abuse
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 09:00 PM
What about Y?
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
24 Mar 2012 09:02 PM
@1billybob1,

If you want it always positioned in the middle, no matter the size of the screen, use Scale for X and Y:

gui.Position = UDim2.new(0.5, 0, 0.5, 0)

Keep in mind that scale is a percentage, so 0.5 -> 50%, which is half-way-across on the screen.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
24 Mar 2012 09:02 PM
@Flurite

That'll put the corner in the middle...
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
24 Mar 2012 09:04 PM
@MrNicNac,

Oh yeah..

gui.Position = UDim2.new(0.5-(gui.Size.X*0.5), 0, 0.5-(gui.Size.Y*0.5), 0)

..I think that's right..
Report Abuse
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 09:06 PM
I don't need it in script though, so would it be: X - (0.5, 0) Y - (0.5, 0)???
Report Abuse
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 09:07 PM
I did that, and it's like 2 inches away from the exact middle.
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
24 Mar 2012 09:09 PM
@1billybob1,

Try my last suggestion.
Report Abuse
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 09:14 PM
Is there any way I can put it in the middle by typing it in the properties box? Instead of scripting it?
Report Abuse
DivineJoker is not online. DivineJoker
Joined: 02 Nov 2011
Total Posts: 41
24 Mar 2012 09:16 PM
Why not use the command bar?

† KMXD †
Report Abuse
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 09:17 PM
I did, it had error in output, (gui:1: attempt to index global 'gui' (a nil value)
Report Abuse
DivineJoker is not online. DivineJoker
Joined: 02 Nov 2011
Total Posts: 41
24 Mar 2012 09:18 PM
Well you have to have a path to the Gui. . . Like game.StarterGui.WhateverUntilItIsTheGui

† KMXD †
Report Abuse
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 09:19 PM
Now it says, Size is not a valid member of Screengui.
Report Abuse
DivineJoker is not online. DivineJoker
Joined: 02 Nov 2011
Total Posts: 41
24 Mar 2012 09:20 PM
Size isn't a property of a GUI, go farther until you reach a frame or something.

† KMXD †
Report Abuse
1billybob1 is not online. 1billybob1
Joined: 15 Jun 2008
Total Posts: 4852
24 Mar 2012 09:22 PM
Now it says, (:1: attempt to perform arithmetic on field 'X' (a userdata value)
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
24 Mar 2012 10:32 PM
JUST

Subtract half the GUIs size from .5
Report Abuse
Flurite is not online. Flurite
Joined: 03 Apr 2011
Total Posts: 5386
25 Mar 2012 07:31 AM
@1BillyBob1,

We are not talking about the ScreenGui. If you want GUIs to be visible in the game, then you need to insert GUIs such as TextLabels, TextButtons, and all the others INSIDE the ScreenGui (parented under the ScreenGui). Then, you can set it's position in the middle of the screen using the sample code I gave you.
Report Abuse
blueymaddog is not online. blueymaddog
Joined: 23 Sep 2009
Total Posts: 5459
25 Mar 2012 08:15 AM
gui.Position = UDim2.new(0.5,0,0.5,0)-(gui.Size/2)
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
25 Mar 2012 08:17 AM
Can UDim2 support divides just like that :O
I thought that you would need to -gui.Size.X.Scale/2.. etc
Report Abuse
blueymaddog is not online. blueymaddog
Joined: 23 Sep 2009
Total Posts: 5459
25 Mar 2012 08:21 AM
I though it would work because you can do it with Vector3 :3
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
25 Mar 2012 08:24 AM
Hah.. I was right for once :PP

UDim2 is a userdata and you can't divide it :PP
Report Abuse
blueymaddog is not online. blueymaddog
Joined: 23 Sep 2009
Total Posts: 5459
25 Mar 2012 08:26 AM
then why does it work with Vector3? O_o
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
25 Mar 2012 08:30 AM
Mysteries of life
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image