Calculating sizes for text bounds is so inconsistent

hey, does anyone know how this works?
I’m trying to make a username tag system which offsets the background frame to fit the text, but I already tried fixing this for 2 weeks already, I’m losing my mind :angst:

source code:

local usernameDisp = script.Parent.Parent.Parent.Parent:WaitForChild("UsernameDisplay")
local coolframe = script.Parent:WaitForChild("coolframe")
local textlabel = script.Parent:WaitForChild("TextLabel")

local textService = game:GetService("TextService")
local params ="GetTextBoundsParams")
params.Text = textlabel.Text
params.Font ="rbxasset://fonts/families/Montserrat.json", Enum.FontWeight.Medium, Enum.FontStyle.Normal)
params.Size = 23
params.Width = 99999999

local bounds = textService:GetTextBoundsAsync(params)
bounds =, math.ceil(bounds.Y))

local function scale(x, y, screenGui)
	local absoluteSize = screenGui.AbsoluteSize
	return, 0, y/absoluteSize.Y, 0)


for i = 1, 15 do
	task.wait(1 * i)
	local size = scale(bounds.X, bounds.Y, usernameDisp)
	coolframe.Size = size