Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i keep a GUI proportional?

Lets say I have a trading card I want to display on screen. In order to not get stretched images, the height and width must be proportional in pixels.

A trading card is about 2.43 inches wide and 3.43 inches tall. Thus you can represent it with UDim2.new(0, 243, 0, 343) and it would look just fine. However, something like UDim2.new(.243, 0, .343, 0) Would not work as the screen stretches the GUI.

The dilemma is, how would I get the GUI to size itself proportionally to the screen so it remains cross compatiable, yet keep a constant ratio of height and width?

1 answer

✓ Accepted answer

If you set the SizeConstraint to RelativeXX or RelativeYY, the scale factors will both be in terms of either the width or height of the screen so the values will represent the same lengths.

3 comments

0

Works just as I need it. Thanks!

0

Nice but I would argue that you could just use the scale part of the UDim2 which is UDim2.new(xscale,ypixels,yscale,ypixels)

0

it is scale.

This discussion is preserved as it was. New answers, comments, and votes are closed.