How do you make shaky text?

Is there any way that I can have the word be nore accuratly placed in the right spot? Sometimes when i use a different font or make it a little bold with a stroke, it places diffrent than a regular textlabel would.

This game show my problem.

(P.s., i know that i need to add the text to move down to thr next column but I haven’t added it yet.

Try checking out TextService:GetTextboundsAsync(). I worked on a bit more of a complex system but here is the relevant function I use to draw the text if you are interested:

function TextBoxHandler:AddText(text: string, effects: {TextEffect}?, ...: TextArguments)
	local textArguments = {...}
	
	local params = Instance.new("GetTextBoundsParams")
	-- params.Text = text
	params.Font = self.Speaker.Font
	params.Size = self.Speaker.FontSize
	params.Width = self.Root.AbsoluteSize.X
	
	local startPoint = self._currentTextPos
	local labelList = {}
	for word in text:gmatch("%S+") do
		word = word .. " "
		params.Text = word
		local textSize = TextService:GetTextBoundsAsync(params)
		if self._currentPos.X + textSize.X > self.Root.AbsoluteSize.X then
			self._currentPos = Vector2.new(self._defaultPos.X, self._currentPos.Y + self.Speaker.FontSize)
		end

		for i = 1, #word do
			self._currentTextPos += 1
			local c = word:sub(i, i)

			params.Text = c
			local textSize = TextService:GetTextBoundsAsync(params)

			local charLabel = Instance.new("TextLabel")
			charLabel.Size = UDim2.fromOffset(textSize.X, textSize.Y)
			charLabel.Position = UDim2.fromOffset(self._currentPos.X, self._currentPos.Y)
			charLabel.Text = c
			charLabel.Transparency = 1
			charLabel.FontFace = self.Speaker.Font
			charLabel.TextSize = self.Speaker.FontSize
			charLabel.TextColor3 = self.Speaker.TextColor
			charLabel.RichText = true
			charLabel.Name = tostring(self._currentTextPos)
			charLabel.Parent = (self.Root :: Frame) :: Instance
			table.insert(labelList, charLabel)
			

			self._textLabels[self._currentTextPos] = charLabel

			self._currentPos += Vector2.new(textSize.X, 0)
		end
	end
	
	self._textLabels[#self._textLabels]:Destroy()
	
	if effects then
		for i, effect in effects do
			effect(labelList, startPoint, table.unpack(textArguments[i] or {}))
		end
	end
	
	local charDelays = self.Speaker.CharDelays or {} :: {[string]: number}
	for _, label in labelList do
		label.Transparency = 0
		label.BackgroundTransparency = 1
		
		local charDelay = charDelays[label.Text]
		if charDelay then
			task.wait(charDelay)
		else
			task.wait(self.Speaker.SpeakingDelay)
		end
	end
	
	-- effect(labelList, startPoint, ...)
end
2 Likes