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

Perfect square on EVERY ScreenGui? Is this possible?

Asked by
WoTrox 345 Moderation Voter
5 years ago

I want to make a perfect square frame (100 by 100, if possible) in the perfect middle of the screen. But when I use the Offset, it's 100 by 100 pixel on every device, so it's a perfect square everywhere, but 100 pixel on a phone is too big. When I use Scale, it's 100 pixel on my screen, but on an Xbox its 117 by 126. That's not a square. Same thing at position. Do someone know how to make a perfect ~100 by 100 in the perfect middle of the screen in each device?

0
i dont think that is possible unless you can receive the displays dimensions somehow Fad99 286 — 5y
0
I think you need to use a uiRatioConstraint but i'm not sure because the wiki is down but give it a try put one in the frame and maybe look at the propertyes and the size of the frame it should has some warning signs Luka_Gaming07 534 — 5y
0
I have an idea for your answer to your question Eternalove_fan32 188 — 5y
0
I'm sorry you had to wait so long but I found the solution Eternalove_fan32 188 — 5y
View all comments (2 more)
0
@Eternalove_fan32 ? WoTrox 345 — 5y
0
Yes Eternalove_fan32 188 — 5y

2 answers

Log in to vote
6
Answered by
megukoo 877 Moderation Voter
5 years ago

You can use a UIAspectRatioConstraint to achieve this. You can insert it in a GuiObject.

0
Thank you so much!! WoTrox 345 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Made 100% by @Eternalove_fan32

01--Variable
02local ScreenGui = script.Parent.ScreenGui
03--Create a new Frame
04local Frame = Instance.new("Frame",ScreenGui)
05--Change the Properties of the new Frame
06Frame.AnchorPoint = Vector2.new(0.5,0.5)
07Frame.Position = UDim2.new(0.5,0,0.5,0)
08Frame.Size = UDim2.new(0.25,0,0.25,0)
09local function SetFrameSize () --You can also replace everything in the function is by Frame.SizeConstraint and here that what you prefer
10 
11local Choice = math.random(1,2)
12if Choice == 1 then
13    Frame.SizeConstraint = Enum.SizeConstraint.RelativeXX
14elseif Choice == 2 then
15    Frame.SizeConstraint = Enum.SizeConstraint.RelativeYY
16   end
17end
18SetFrameSize()

Here you can skip from line 10 to 15 and select only one of the two relatives and replace them like this:

01--Variable
02local ScreenGui = script.Parent.ScreenGui
03--Create a new Frame
04local Frame = Instance.new("Frame",ScreenGui)
05--Change the Properties of the new Frame
06Frame.AnchorPoint = Vector2.new(0.5,0.5)
07Frame.Position = UDim2.new(0.5,0,0.5,0)
08Frame.Size = UDim2.new(0.25,0,0.25,0)
09local function SetFrameSize ()
10 
11Frame.SizeConstraint = Enum.SizeConstraint.RelativeXX -- (Here I changed the script)or Frame.SizeConstraint = Enum.SizeConstraint.RelativeYY
12 
13   end
14end
15SetFrameSize()

You have to copy the code and put it in the StarterGui without anything else. I hope this has helped you ^-^ (Your @Eternalove_fan32)

Answer this question