UIStrokeFix 2.0

With some help, I made a script a while back that scaled UIStroke instances to the same thickness relative to your screen the same as you would see in studio. This helped small screen users such as phone players play games without having huge strokes in the way. Here is an example of what UIStrokeFix fixes:

Expectation

image

Reality

image

In short terms, this script makes the UI Strokes across all screens to be the same scale, so that in the ‘Reality’ picture above, it would be just like the ‘Expectation’.

The old version of UIStrokeFix was very hard to set up, and it had bugs. This one is improved with extra features and bugs fixed.

Bugs Fixed
  • Whenever you reset, the strokes would be scaled by 2x
New Features
  • Automatically scales new UI Strokes that are added during the game
  • Made the code cleaner

Anyways here is the model: UIStrokeFix 2.0 - Creator Store (roblox.com). You just place this under StarterPlayerScripts and your good to go. If you have any questions feel free to comment.

Code
-Made by @CaelmDev & @BendsSpace

print("This game is using UIStrokeFix 2.0 by @CaelmDev and @BendsSpace.")

local plr = game:GetService("Players").LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")
local BASE_SIZE = 1200

local function updateStroke(uiStroke)
	local initialStrokeThickness = uiStroke.Thickness
	local camera = game:GetService("Workspace").CurrentCamera

	local function updateStrokeThickness()
		uiStroke.Thickness = initialStrokeThickness * camera.ViewportSize.X / BASE_SIZE
	end

	camera:GetPropertyChangedSignal("ViewportSize"):Connect(updateStrokeThickness)
	updateStrokeThickness()
end

for i, descendant in pairs(plrGui:GetDescendants()) do
	if descendant:IsA("UIStroke") then
		updateStroke(descendant)
	end
end

plrGui.DescendantAdded:Connect(function(descendant)
	if descendant.Name == "UIStroke" then
		updateStroke(descendant)
	end
end)
3 Likes