There are no tutorials on this and I cant seem to figure out how to keep the frame onto the screen using this method. I also don't know if I have to use code to do this.
A UIAspectRatioConstraint ensures that a GuiObject maintains a particular aspect ratio even if it’s size is set as a percentage of its parent. If an object with this constraint is also under the control of a UILayout such as UIGridLayout, then the constraint controls the object’s size and overwrites any size the layout would apply.
A UIAspectRatioConstraint can be applied to a GuiObject by parenting it to that object.
When applied to a GuiObject, the UIAspectRatioConstraint will make sure that the object’s ratio is maintained by the value defined in AspectRatio. The AspectType sets what determines the maximum size of the object. When set to FitWithinMaxSize, the constraint will make the object the maximum size it can be within the AbsoluteSize of the element. When set to ScaleWithParentSize, the element’s maximum size will be the size of the parent while still maintaining the aspect ratio. Last, the DominantAxis will determine which axis to use when setting the new size of the element.
--Example GUI.RANDOMGUINAME.AnchorPoint = Vector2.new(0.5,0.5) -- Now it will center values. Therefore... GUI.RANDOMGUINAME.Size = UDim2.new(0.5,0,0.5,0) -- This will be half of the screen. GUI.RANDOMGUINAME.Position = UDim2.new(0.5,0,0.5,0) -- This will center it.
Example of SizeConstraint within your GUI script
local gui = script.Parent local parent = gui.Parent local function update() gui.SizeConstraint = parent.AbsoluteSize.x < parent.AbsoluteSize.y and Enum.SizeConstraint.RelativeYY or Enum.SizeConstraint.RelativeXX end update() parent:GetPropertyChangedSignal("AbsoluteSize"):Connect(update)