ScrollingFrame Bar Horizontal / Vertical Scaling Issue

Greetings To Everyone here!,

I’ve run into this problem several times when working with horizontal scrollbars, especially after replacing the default (Top, Middle, Bottom) images with custom ones. Everything looks fine in Studio on my main window, but when I switch to a different device, such as a mobile phone, the scrollbar scales vertically, making it appear offset from its original size. On the other hand, when testing on a larger resolution device like 1920×1080, it scales the opposite way, shrinking instead of keeping its intended proportions.

  • | The Normal Size for it is represented on this picture:
    image
  • | When Changing Device to Mobile or minimum screen sizes:
    image
  • | Last When Tweaking Device to Larger Resolution Based Devices as HD1920x1080:
    image

Hope Y’all understood my issue, and i’m interested in a solution for it!

I’ve recently found a reliable way to fix scrollbar scaling issues across devices is to calculate the screen’s viewport size and divide it by the resolution you want your scrollbar to scale to. This keeps the scrollbar scale identical on all screen sizes.

The script is a LocalScript placed in StarterPlayerScripts:

  • | ------
task.wait(1)

local player = game.Players.LocalPlayer

local function ScaleBar(ScrollingFrame)
   local basethickness = ScrollingFrame.ScrollBarThickness
   local scaleFactor = workspace.CurrentCamera.ViewportSize.X / 1280
   ScrollingFrame.ScrollBarThickness = basethickness * scaleFactor
end

local function autoscalestroke()
   for _,gui in ipairs(player.PlayerGui:GetDescendants()) do
   	if gui:IsA("ScrollingFrame") then
   		ScaleBar(gui)
   	end
   end
end

player.PlayerGui.DescendantAdded:Connect(function(d)
   if d:IsA("ScrollingFrame") then
   	ScaleBar(d)
   end
end)

You can adjust the goal resolution depending on the scrollbar size you currently use, in my case scrollbar size is 10

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.