Help with individual text frame sizing inside of BillboardGui

I have a BillboardGui, a frame (with more textframes in it) in order to create the effect of a normal text frame with a long string. You might ask “why do they need all of those text frames” – the answer to that is because I need to individually manage each letter of the text (position, color, size, etc) to make nametag effects in my game.

What do I need help with? I need to make sure the size is consistently the same with all of the letters and frames just as you would if there was one frame with TextScaled on.

Here’s my current code:

local text = player.Name
local TextFontSize = 30
local TextSize = game.TextService:GetTextSize(text, TextFontSize, Enum.Font.Gotham, Vector2.new(usernameFrame.Size))


for i = 1, #text do
    local CharacterLabel = Instance.new("TextLabel")
    CharacterLabel.ZIndex = 2
    CharacterLabel.BackgroundTransparency = 1
    CharacterLabel.Font = Enum.Font.Gotham
    CharacterLabel.TextSize = TextFontSize
    CharacterLabel.Size = UDim2.new(0, 1/#text, 0, 1)
    CharacterLabel.Position = UDim2.new((i-1)/#text, 0, 0.5, 0)]
    CharacterLabel.AnchorPoint = Vector2.new(0.5, 0.5)
    CharacterLabel.Text = string.sub(text, i, i)

    CharacterLabel.Parent = usernameFrame
end

This is the issue:
https://cdn.discordapp.com/attachments/1138164798652166264/1186204672437006356/Screen_Recording_2023-12-18_at_1.12.47_AM.mov?ex=65926630&is=657ff130&hm=8a733ed902d1778d0e07e6c895a044b3b1e2e33979b9935fa8bdd2635bda006c& (File too big so had to make do)

I want each letters to be evenly spaced, appear how it normally would, and when manipulating the camera scale and position properly inside of the frame.

1 Like

for your example, you would probably heavily benefit from using the property of textlabels called RichText. it allows you to do everything you described in your post but with a singular textlabel. the formatting is similar to HTML tags, and roblox provided documentation on how to use it here. if you still want to use your method of text, you probably have to make the billboardgui use offset instead of scale because your character labels use scale for their position.

Thank you for the suggestions, I will try them soon! As for using RichText, I don’t believe that it will fit my use case due to me wanting to change variables such as Positon.

Unfortunately, this doesn’t fit my use case because making the BillboardGui’s position offset instead of scale as it just makes the frame larger.

I ended up solving the problem by myself. If anyone is having an issue like this, use offset for the parent text frame with a UiListLayout & UIAspectRatioConstraints. Works like a charm, although still not the best solution I guess.

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