PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

SizeConstraint

GuiObject

SizeConstraint

SizeConstraint works in conjunction with GuiObject.Size to determine the screen size of a UI element. The SizeConstraint enum will determine the axes that influence the scalar size of an object. This property is useful for creating onscreen controls that are meant to scale with either the width or height of a parent object, but not both. This preserves the aspect ratio of the UI element in question. For example, setting to RelativeYY with a Size of {1, 0}, {1, 0} will make the UI element square, with both the X and Y sizes equal to the parent element’s Y size.


Code Samples


SizeConstraint

This code sample sets the SizeConstraint of a parent UI element.

local guiObject = script.Parent
guiObject.SizeConstraint = Enum.SizeConstraint.RelativeXX