How do I make a text Bold in a script?

I’ve been trying to make a script which displays text, but I can’t seem to make the text Bold
For clarification: I do Not want RichText, I know there’s FontFace.Bold and FontFace.Weight but they don’t work if I try to do:

Subtitle.FontFace.Bold = true
-- or
Subtitle.FontFace.Weight = Enum.FontWeight.Bold

My current localscript

-- Player
local Player = game:GetService("Players").LocalPlayer
local PlayerUI = Player.PlayerGui

function AddSubtitle(Text)
	-- "text" is the text to subtitle
	
	-- Set UI
	local UI = Instance.new("ScreenGui"); UI.Parent = PlayerUI
	local Frame = Instance.new("Frame"); Frame.Parent = UI
	local Subtitle = Instance.new("TextLabel"); Subtitle.Parent = Frame
	UI.Name = "Subtitle"
	
	-- Frame
	Frame.Size = UDim2.new(0.5, 0, 0.1, 0)
	Frame.Position = UDim2.new(0.25, 0, 0.75, 0)
	Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
	Frame.BackgroundTransparency = 0.5
	Frame.BorderSizePixel = 0
	
	Subtitle.FontFace.Weight = Enum.FontWeight.Bold
	
	-- Subtitle
		-- Looks
	Subtitle.Position = UDim2.new(0, 0, 0, 0)
	Subtitle.Size = UDim2.new(1, 0, 1, 0)
	Subtitle.Font = Enum.Font.Roboto
	Subtitle.TextSize = 1
	Subtitle.TextScaled = true
	Subtitle.BorderSizePixel = 0
		--Colors
	Subtitle.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
	Subtitle.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
	Subtitle.TextColor3 = Color3.fromRGB(255, 255, 255)
		-- Transparency
	Subtitle.BackgroundTransparency = 0.5
	Subtitle.TextStrokeTransparency = 1
		-- Set Text
	Subtitle.Text = Text
end

AddSubtitle("This is an example test")
4 Likes

Why not use RichText?
Check this code

-- Player
local Player = game:GetService("Players").LocalPlayer
local PlayerUI = Player.PlayerGui

function AddSubtitle(Text,Text2)
	-- "text" is the text to subtitle

	-- Set UI
	local UI = Instance.new("ScreenGui"); UI.Parent = PlayerUI
	local Frame = Instance.new("Frame"); Frame.Parent = UI
	local Subtitle = Instance.new("TextLabel"); Subtitle.Parent = Frame
	UI.Name = "Subtitle"

	-- Frame
	Frame.Size = UDim2.new(0.5, 0, 0.1, 0)
	Frame.Position = UDim2.new(0.25, 0, 0.75, 0)
	Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
	Frame.BackgroundTransparency = 0.5
	Frame.BorderSizePixel = 0

	Subtitle.FontFace.Weight = Enum.FontWeight.Bold

	-- Subtitle
	-- Looks
	Subtitle.Position = UDim2.new(0, 0, 0, 0)
	Subtitle.Size = UDim2.new(1, 0, 1, 0)
	Subtitle.Font = Enum.Font.Roboto
	Subtitle.TextSize = 1
	Subtitle.TextScaled = true
	Subtitle.BorderSizePixel = 0
	--Colors
	Subtitle.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
	Subtitle.TextStrokeColor3 = Color3.fromRGB(255, 255, 255)
	Subtitle.TextColor3 = Color3.fromRGB(255, 255, 255)
	-- Transparency
	Subtitle.BackgroundTransparency = 0.5
	Subtitle.TextStrokeTransparency = 1
	-- Set Text
	
	--Subtitle.FontFace = Font.new("rbxasset://fonts/families/Arial.json")
	Subtitle.RichText = true
	Subtitle.Text = "<b>" .. Text  .."</b>" .. " " .. Text2

end

AddSubtitle("This is an example test","and this is not bold")
3 Likes

I thought I could use FontWeight or FontFace instead,
I never actually thought to use

Subtitle.Text = "<b>" .. Text .. "</b>"

I thought I needed to put it in the addsubtitle() text, my bad

3 Likes

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