Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I set my Frame in the center of the screen?

Asked by 7 years ago

I feel that there should be a simple couple of position coordinates, like {1,0,1,0} to fill up the screen in Size.

I've been looking everywhere, and I've tried lots of solutions in other places.

0
How big is your frame? Viking359 161 — 7y
0
{0, 250},{0, 150} Joz2015 6 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

There is a simple solution that I use to center a gui. I do

local size = script.Parent.Size
script.Parent.Position = UDim2.new(.5 - (size.X.Scale / 2), -(size.X.Offset / 2), .5 - (size.Y.Scale / 2), size.Y.Offset / 2)

What this does, is put the X axis to the middle, and subtract half of the size X scale, and the same for the Y axis.

But what you put in your question is different than what you put in the question title. So, to make the frame fill up the screen, do

script.Parent.Position = UDim2.new(0, 0, 0, -200) --to fill up Roblox's top bar thingy.
script.Parent.Size = UDim2.new(1, 0, 2, 0)

Hope this helps!!

0
Also, the position is not the same as size. Setting the position does not set size. hiimgoodpack 2009 — 7y
0
Thanks. Sorry if I was unclear: I didn't want size, I already know that. I was just saying that it's easy to find out how to do it for size and uneasy to find out how to do it for position. But I know now, so lol Joz2015 6 — 7y
Ad

Answer this question