I am having trouble preloading the font of a TextLabel within its localscript. The TextLabel is transparent by default and its transparency is changed within the script. I have tried:
local label = script.Parent
local ContentProvider = game:GetService("ContentProvider")
ContentProvider:PreloadAsync({Font.fromName("Sarpanch").Family})
and
local label = script.Parent
local ContentProvider = game:GetService("ContentProvider")
ContentProvider:PreloadAsync({label})
local label = script.Parent
local ContentProvider = game:GetService("ContentProvider")
local font = Enum.Font.Gotham -- Replace with your specific font enum
-- Preload the font
local success, errorMessage = pcall(function()
ContentProvider:PreloadAsync({label})
end)
if success then
print("Font preloaded successfully.")
else
warn("Failed to preload font: " .. errorMessage)
end
-- Set the font after preloading
label.Font = font
Is there any way to make the font weight different? This code works, but it seems the font can only be its regular weight using Font, since FontFace is the only property that has the option to change that, but doing label.FontFace.Family = "Sarpanch" and label.FontFace.Weight = Enum.FontWeight.ExtraBold does not work with the preload.