There are still cases where you should maintain aspect ratio instead of solely depending on scale.
EXAMPLE: Sizing guis inside of scrolling frames. If you only used scale, when you change the CanvasSize everything would stretched or shrunk on the axis you changes. Aspect ratio solves this.
Sorry for re activating this, to get that type of scaling, you just have to do the following:
local CurrentViewport = game.Workspace.Camera.ViewportSize
local ReferenceViewportSize = Vector2.new(1920, 1080) -- change this to whatever screen size you want as reference.
local newViewport = Vector2.new(CurrentViewport.X/ReferenceViewport.X, CurrentViewport.Y/ReferenceViewport.Y)
-- Reference formula use:
TextLabel.TextSize * newViewport.Y -- Based on Text Bound property on the text label, X auto scales for Y, in which Y is TextSize.
Frame.Size = UDim2.new(0,100*newViewport.X,0,100*ReferenceViewportSize.Y)
The NewViewport is a multiplier where we divided the current to the reference, where it translate it into percentage
If both are the same size, then the result is equals to 1, meaning it doesn’t change anything.
If it is less than, then it will be a multiplier less than 1, which will make it smaller while if it is bigger then it is more than 1, which of course increases the size.
I actually use this to make an AutoScale for text.
Why I don’t just use text scaled? Well using this formula has more advantages, such as being able to edit the text size at will.
It is recommended, that this be used as a outer layer rather than an inner layer (Aka the ut most top of the heighercy before the ScreenGUI, why? If it is parented to another frame, and you want that frame be dynamic, while inside has autoscale, then instead of the viewportSize as your current viewport, change it to the AbsoluteSize (aka Translated to Pixels) to achieve the same effect. (You might also change the reference to the parented UI’s CONSTANT (aka non changing) absolute size))