Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to allow Text to stay inbounds of a TextBox while following it if it surpasses?

Hello,

This is a quick question. I’ve recently programmed a custom chat. Everything works smoothly, however, with the chat bar—what is used to type the message into—whenever the text seems to reach the furthest edge of the GUI, it will just continue outward. That was expected, so I attempted to set the TextWrapped property to true, with that resulting in the string completely disappearing when it reached the end. I turned that off. TextTruncate will simply format a triple dot at the end of the string to indicate it’s gone further, so I’ve found myself sitting with ClipsDescendants enabled. Although, this still doesn’t solve anything, as it won’t follow with what I type, and I can’t see anything.

Is there a possible way to keep the text within the TextBox like I have with ClipsDescendants, yet have it follow, like it would if you were to reach the end of a search bar on a browser, within ROBLOX? Or must I have it push the chat bar downwards to let TextWrapped fit it within the bar like the default chat does?

1 comment

0

What's your discord?

1 answer

I looked through the ROBLOX Chat script to find how they do it, it's pretty simple; keep TextWrapped on.

Here's an example.

local TextBox = script.Parent.TextBox
local TextService = game:GetService('TextService')

local function ReturnTextSize()
	return TextService:GetTextSize(
		TextBox.Text,
		TextBox.TextSize,
		TextBox.Font,
		Vector2.new(TextBox.AbsoluteSize.X, 10000)
	)
end

TextBox:GetPropertyChangedSignal('Text'):Connect(function()
	local TextSize = ReturnTextSize()
	TextBox.Size = UDim2.new(0,200, 0, TextSize.Y)
end)

2 comments

0

Hey, I already know this code, I wrote my own version standing by, but I made adjustments based on your code, and am yet still experiencing some issues, could I DM you about them?

0

Ziffixture#0152

This discussion is preserved as it was. New answers, comments, and votes are closed.