How to solve UIStroke appearing too big on mobile devices

This topic is over. This is strictly for tutorials. None of this was necessary. I will try @bluebxrrybot 's script. If it works, okay, if it doesn’t then I’ll try again.

Good night.

Okay, so firstly I want to apologize because I may have been too defensive because I believed my method was right.

Secondly, I agree that both can be used, but @bluebxrrybot 's method is probably the better choice.

Here is my version of the script, with little to no errors.

local Player = game.Players.LocalPlayer

local CurrentCamera = game.Workspace.CurrentCamera

local PlayerGui = Player.PlayerGui.MainUI

local Thickness = 1.5

local ViewportRatio = CurrentCamera.ViewportSize.X / CurrentCamera.ViewportSize.Y

local UserInputService = game:GetService("UserInputService")
local TouchEnabled = UserInputService.TouchEnabled


for i, v in pairs(PlayerGui:GetDescendants()) do
	if v:IsA("UIStroke") then
		if TouchEnabled then
			v.Thickness = v.Thickness / (Thickness * ViewportRatio)
		end
	end
end

Edit: I tested this and it works in Studio.

I updated the script a little bit:

local studiosize = Vector2.new(1920,1080)


local function getratio()
	return workspace.CurrentCamera.ViewportSize.Y / studiosize.Y
end

local function onobject(stroke: UIStroke)
	if stroke:IsA("UIStroke") then
		stroke:SetAttribute("Thickness", stroke:GetAttribute("Thickness") or stroke.Thickness)
		stroke.Thickness = stroke:GetAttribute("Thickness") * getratio()
	end
end

local player = game.Players.LocalPlayer
for _, stroke in pairs(player.PlayerGui:GetDescendants()) do
	onobject(stroke)
end

player.PlayerGui.DescendantAdded:Connect(onobject)

workspace.CurrentCamera.Changed:Connect(function()
	for _, stroke in pairs(player.PlayerGui:GetDescendants()) do
		onobject(stroke)
	end
end)

Whenever the CurrentCamera changes any value, it will basicly update the stroke. When you resize window on computer for example for dragging it to other monitor, it can be pretty annoying to see stroke again big, so i added this simple update to do it. Any reviews?

2 Likes