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?
✓ ANSWER ACCEPTED
Perfect square on EVERY ScreenGui? Is this possible?
2 answers
✓ Accepted answer
You can use a UIAspectRatioConstraint to achieve this. You can insert it in a GuiObject.
1 comment
0
Thank you so much!!
Made 100% by @Eternalove_fan32
--Variable
local ScreenGui = script.Parent.ScreenGui
--Create a new Frame
local Frame = Instance.new("Frame",ScreenGui)
--Change the Properties of the new Frame
Frame.AnchorPoint = Vector2.new(0.5,0.5)
Frame.Position = UDim2.new(0.5,0,0.5,0)
Frame.Size = UDim2.new(0.25,0,0.25,0)
local function SetFrameSize () --You can also replace everything in the function is by Frame.SizeConstraint and here that what you prefer
local Choice = math.random(1,2)
if Choice == 1 then
Frame.SizeConstraint = Enum.SizeConstraint.RelativeXX
elseif Choice == 2 then
Frame.SizeConstraint = Enum.SizeConstraint.RelativeYY
end
end
SetFrameSize()
Here you can skip from line 10 to 15 and select only one of the two relatives and replace them like this:
--Variable
local ScreenGui = script.Parent.ScreenGui
--Create a new Frame
local Frame = Instance.new("Frame",ScreenGui)
--Change the Properties of the new Frame
Frame.AnchorPoint = Vector2.new(0.5,0.5)
Frame.Position = UDim2.new(0.5,0,0.5,0)
Frame.Size = UDim2.new(0.25,0,0.25,0)
local function SetFrameSize ()
Frame.SizeConstraint = Enum.SizeConstraint.RelativeXX -- (Here I changed the script)or Frame.SizeConstraint = Enum.SizeConstraint.RelativeYY
end
end
SetFrameSize()
You have to copy the code and put it in the StarterGui without anything else. I hope this has helped you ^-^ (Your @Eternalove_fan32)
This discussion is preserved as it was. New answers, comments, and votes are closed.

6 comments
i dont think that is possible unless you can receive the displays dimensions somehow
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
I have an idea for your answer to your question
I'm sorry you had to wait so long but I found the solution
@Eternalove_fan32 ?
Yes