Textlabel Gap Issue

The issue is the more the text labels, the gap between the text label becomes smaller. And the less the text labels, the gap is more bigger.

Note: This is a billboard Gui

How can I keep the consistent between the text labels?

With more textlabels/longer name:
image

With less textlabels/shorter name:
image

local plrName = "Test"
local gapBetweenLetters = 0.06

    -- local xOffset = 0.27
    local yOffset = 0.5
    
    for i = 1, #plrName do
        local newLabel = LabelTemplate:Clone()
        newLabel.Parent = playerFrame
        local currentLetter = string.sub(plrName, i, i)
        local textSize = TextService:GetTextSize(currentLetter, 18, currentFont, Vector2.new(1000, 1000))
        
        newLabel.Text = currentLetter
        newLabel.Name = currentLetter
        
        print("width of letter", currentLetter, "is", textSize.X)
        
        newLabel.Position = UDim2.new((i - 1) * gapBetweenLetters, 0, yOffset, 0)
    end
1 Like

Instead of scripts, Have you tried putting a

UiListLayout inside a frame, then putting the textlabels there and adjusting the Padding?

Why not just use one single text label

I don’t know why you are using individual text labels as that seems incredibly impractical especially for single characters, but you still want a solution right?

It’s because you aren’t keeping the actual newLabel size scaled the size of the letter. So any characters that happen to be bigger or smaller than the actual bounds.

newLabel.Size = UDim2.fromOffset(textSize.X,textSize.Y)

I have, it doesn’t turn out correct

I am using individual textlabels because I need to animate the letters individually.

As for the solution you provided, the issue is that when I zoom out with my camera the letters become bigger and when I zoom in the letters become smaller.

Oh you’re using billboardgui’s, incredibly common for the camera to affect the sizing. I remember I fixed mine by changing the actual billboardgui size to scale instead of offset, and the same with all guis under it.