UIStrokes Scaling made simple

Yall all had an issue scaling UISrokes right?

Well for that i made a simple formula that will let you scale them properly
I were in need of scalable Border/UIStroke/RichText and i decided to mess around with formulas and somehow managed to find a working method.

If you want short simple answer here is the formula:

local size = 50
local ViewPort = workspace.CurrentCamera.ViewportSize
math.min(ViewPort.X,ViewPort.Y)/ViewPort.Y *size

How does it work?
It works similar to UIAspectRatioConstraint
If X is bigger than Y then we round it to Y and devide by Y and multiply by size
I haven’t found any tutorial like mine with this answer; It were either some meh UI bloatware frameworks or such plus they all were doing this simple thing WRONG.
Funny how i figured out answer randomly :skull:

UPDATE:

Hower i just made another formula (with ChatGPT’s help this time) that works similarly and fully replicates UIAspectRatioConstraint
IF YOUR UISTROKE DOESNT USE UIAspectRatioConstraint THEN USE PREVIOUS FORMULA!

--Tips:
	--1920/1080 = 1.7777777777777777 Ratio
	--Ratio*Y = X
	--X/Ratio = Y
local size = 50
local ViewPort = workspace.CurrentCamera.ViewportSize
local Ratio = Vector2.new(1080, 1080) -- `UIAspectRatioConstraint`'s Ratio would be 1
local Scaled = ((ViewPort.X/ViewPort.Y>Ratio.X/Ratio.Y and ViewPort.Y/Ratio.Y) or ViewPort.X / Ratio.X) *size

Goodluck!

2 Likes

Is this for like, when it’s on a BillboardGUI?

No.
Only for 2D.
It is very expensive for 3D; Consider stacking UI Objects ontop of each other for this effect/canvas groups

Its not new, and most of them work, especially the last one i linked. which I use personally.

The problem with them is they simply don’t work as promised.
While they may do work but the point with Thickness is to shrink it down incase it covers your screen.
All they did is devide it by 2?(that stuipid) or do some weird/scary calculations
In other words complete misunderstanding on how screen resolutions work.
Hower im gonna be honest UIStrokeAdjuster - Properly scale your UIStrokes! did it probably the closest; yet still failed with some weird “Studio Resolution” constants.
You still haven’t provided any argument of them doing it right
Also my tutorial is right to the point with formula and not some annoying UI frameworks.
Dont want to look egoistical but please lets be honest here.

Wdym?? I usually use the last one, and it works perfectly on everything.

Kinda, but it works, thats what matters.

If you call these scary calculations, you havent seen scary calculations:

local studioAverage = (STUDIO_SCREEN_SIZE.X + STUDIO_SCREEN_SIZE.Y) / 2
local currentScreenAverage = (camera.ViewportSize.X + camera.ViewportSize.Y) / 2
local scaleFactor = currentScreenAverage / studioAverage

Wdym? go test out one of these, or if you’re to lazy, try the last one i linked. They work. And if it works, why reinvent the wheel? I dont think they are doing anything inherently wrong.

So are all of the ones I linked, you just have to do some digging, people still have to implement yours and make it work, unlike the last one i linked which literally has 2 solutions.

I kinda am?? do some digging before posting something.

1 Like

It is?

1 Like

(post deleted by author)

Billboard GUIs are more specific when it comes to that.
I recomend you to use frames as outline in this case.

Im sorry, but now you are really sounding narcissistic.

It does.

Neither do you?

what is size? oh right, you didnt explain, yet you judge me, just wow.

my code is not dependant on constraints, im not using UIAspectRatioConstraint, just GuiObjects with scale instead of offset.

Pretty well, i would say… Even though these do not exist(i tried something close 100x1000 you mentioned in your post.)

It doesnt, stop assuming nonsense when you havent tried anything i have linked above.

LMAOOO, again, these are simple solutions, not need to overcomplicate this. And that is what matters, if it works, it works, I don’t see why you would have to change something if it works.

What is “complete uneducation on Screen Resolutions” and “hell to see code”?? now you’re just blabbering.

The code I provided is not hard to read, like, at all. A scripter with basic understanding of syntax and math will be able to understand the code, so its not “hell to see”.

This is what any of the posts I linked above do, “full stop!”

Don’t post something that has already been solved, no point.
Also learn some proper grammar and spelling, i had a “hell” of a time reading what you wrote.

Or just use your countries side of the forum, theres Spanish(theres more, I just know theres a spanish one), if that works better for you.

Ok i made another method for scaling
Better than first one if you combine that with UIAspectRatioConstraint
For rest i would still use first method as since it is more simple and looks better on regular non UIAspectRatioConstraint scaled GUI