Didn’t you ever got annoyed by this ?
you just made an AMAZING ui WOW omg so beautiful!
you test on mobile and you see this : the UIStrokes are super thick!
this problem is caused by the fact that the stroke thickness is calculated in pixels, wich is not depending on the size of the screen
so i decided to make a script that would fix it, like if there was a “Scale” property for UIStroke thickness
it’s pretty simple you just need to add an attribute to all your UIStrokes called “ScaleThickness” and set it to a number : the current thickness of your stroke.
Or
you can just paste this line in the command bar :
for _, obj in game:GetDescendants() do
if obj:IsA("UIStroke") then
obj:SetAttribute("ScaleThickness", obj.Thickness)
end
end
The script will do the rest in game!
Here is the script :
local strokes : {UIStroke} = {}
local attribute = "ScaleThickness"
function updateSize(stroke : UIStroke)
if table.find(strokes, stroke) then
local thickness = stroke:GetAttribute(attribute)
stroke.Thickness = thickness * stroke.Parent.AbsoluteSize.Magnitude / 1000
end
end
function addStroke(obj : Instance)
if not obj:IsA("UIStroke") or not obj:GetAttribute(attribute) or not tonumber(obj:GetAttribute(attribute)) then
return
end
table.insert(strokes, obj)
updateSize(obj)
obj.Changed:Connect(function()
if not obj or not obj.Parent then
table.remove(strokes, table.find(strokes, obj))
end
end)
obj.AttributeChanged:Connect(function()
if not obj:GetAttribute(attribute) or not tonumber(obj:GetAttribute(attribute)) then
table.remove(strokes, table.find(strokes, obj))
end
end)
obj.Parent:GetPropertyChangedSignal("AbsoluteSize"):Connect(function()
updateSize(obj)
end)
obj:GetAttributeChangedSignal(attribute):Connect(function()
updateSize(obj)
end)
end
repeat task.wait() until game.Players.LocalPlayer.Character
for _, v in game:GetDescendants() do
addStroke(v)
end
game.DescendantAdded:Connect(addStroke)
paste it inside a LocalScript in StarterGui
and youre done!
if you want – for some reason – a stroke that would not use this system, simply delete the attribute
Demo video :
If you find any bug or problem please give feedback
Have a great day!!