TextLabel text size randomly changing?

Hello!

So I am working on my game’s starter UI and it appears the text randomly changes size and I am not sure why.

It appears normally for a minute and then randomly goes small. Any help?

Expected size:

Then randomly goes small near the end of the loading.

Script:

local replicatedFirst = script.Parent

replicatedFirst:RemoveDefaultLoadingScreen()

local contentProvider = game:GetService('ContentProvider')
local players = game:GetService('Players')
local playerUI = players.LocalPlayer.PlayerGui
local localizationService = game:GetService('LocalizationService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local tweenService = game:GetService('TweenService')

local remotes = replicatedStorage:WaitForChild('Remotes')

local requestData = remotes:WaitForChild('RequestData')


local translator = localizationService:GetTranslatorForPlayerAsync(players.LocalPlayer)


local translatedText = translator:Translate(game, 'Waiting for assets')
local data = translator:Translate(game, 'Waiting for data')
local failedText = translator:Translate(game, 'Data failed to load! Retrying...')
local unableToLoad = translator:Translate(game, 'Unable to load data. Try again later!')
local loadingComplete = translator:Translate(game, 'Loading complete!')

local assetsToPreLoad = {}

for i,v in ipairs(game:GetChildren()) do
    local s,e = pcall(function()
        service = game:GetService(v.Name)
    end)
    if s then
        table.insert(assetsToPreLoad, #assetsToPreLoad + 1, service)
    end
end

contentProvider:PreloadAsync(assetsToPreLoad)

local UI = Instance.new('ScreenGui', playerUI)
UI.DisplayOrder = 9999
UI = Instance.new('Frame', UI)
UI.Size = UDim2.new(1,0,2,0)
UI.Position = UDim2.new(0,0,-1,0)
UI.BackgroundColor3 = Color3.new(1, 1, 1)
UI = Instance.new('TextLabel', UI)
UI.Text = translatedText
UI.Size = UDim2.new(1,0,0.5,0)
UI.Position = UDim2.new(0,0,0.5,0)
UI.TextSize = 30
UI.AutoLocalize = true
UI.Visible = true
UI.BackgroundTransparency = 1
UI.TextColor3 = Color3.new(0.284428, 0.284428, 0.284428)
UI.BackgroundColor3 = Color3.new(1,1,1)
UI.TextXAlignment = 'Center'
UI.TextYAlignment = 'Center'

local t = {
    [1] = '.';
    [2] = '..';
    [3] = '...';
}

local c = 0

repeat
    UI.Text = translatedText..t[(c % 3) + 1]
    c = c + 1
    wait(0.5)
until contentProvider.RequestQueueSize == 0 and c >= 6

c = 0
local datac = 0

local requestDataCoroutine = coroutine.wrap(function()
    repeat
        if datac > 0 then
            wait(10)
        end
        datac = datac + 1
        dataSucceeded = requestData:InvokeServer()
    until dataSucceeded
end)()

repeat
    if datac < 2 then
        c = c + 1
        UI.Text = data..t[(c % 3) + 1]
        wait(0.5)
        print(datac..1)
    else
        UI.Text = failedText..' ('..datac..')'
        wait(.5)
        print(datac..2)
    end
until dataSucceeded or datac > 6

if datac > 6 then
    UI.Text = unableToLoad
else
    wait(1)
    UI.Text = loadingComplete
    for i,v in pairs(UI.Parent.Parent:GetDescendants()) do
        tweenService:Create(v, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
        if v:IsA('TextLabel') then
            tweenService:Create(v, TweenInfo.new(0.5), {BackgroundTransparency = 1; TextTransparency = 1}):Play()
            wait(0.5)
            UI.Parent.Parent:Destroy()
        end
    end
end

TIA for any help!

Is there blank characters at the end of the text? This could possibly be why it does that.

1 Like

Hey there,

I don’t think there are any. I am using the English translation so I would not say there are any. No spaces or anything before the quotation mark. No \n or anything either. Also, TextScaled is disabled so I don’t think an invisible character would do much anyway but I could be wrong.