Need help to make Dialogue fit in one line

Hello,

I want to make a typewriting system similar to in the video.

I can’t seem to figure out a way to make the Text size and position perfectly so it fits on one line.

I’ve tried changing the changing the TextLabel’s size but it doesn’t work.

Video (sorry for the lag):

local TextLabel = script.Parent

wait(5)

local function TypeWrite(name,text)
	TextLabel.Text = name..": "
	wait(.05)
	for i = 1,#text,1 do
		TextLabel.Text = "<font color = 'rgb(255,0,0)'>".. name.."</font>: "..text:sub(1,i)
		wait(.05)
	end
end

TypeWrite("person name","hello, how are you doing today???????????????????????")
2 Likes

I’m pretty sure there is a tween that can do the type writing function for you. not sure about the sizing issue

have you tried turning on textscaled on the label?

Yeah, but it doesn’t give the result I want. (It changes sizes as the text is being added, I want it to be one size at the start and fit the screen in the end)

You might want to consider properties such as .AbsoluteSize

Then use the .Y value to get a textsize that you’d want.
Extremely basic example:

local absolute_size = text_label.AbsoluteSize
main_frame.Size = UDim2.new(0, absolute_size.X / 2, 0, absolute_size.Y / 1.5)

local font_size = math.ceil(absolute_size.Y / 40)
text_lable.TextSize = font_size

This is an example for fitting text within a certain height, you can use these concepts to fit it in a specified width instead.