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
4 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 — 4y
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 — 4y
0
I have an idea for your answer to your question Eternalove_fan32 188 — 4y
0
I'm sorry you had to wait so long but I found the solution Eternalove_fan32 188 — 4y
View all comments (2 more)
0
@Eternalove_fan32 ? WoTrox 345 — 4y
0
Yes Eternalove_fan32 188 — 4y

2 answers

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

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

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

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)

Answer this question