Message Box Rich Text

everytime I type in the message box the italic rich text goes away, how do I fix this?

image
image

I’m confused on what you’re asking, but RichText will not render if you’re editing the text box.

this will detect whenever the TextBox loses its focus and will update the text like so

script.Parent.FocusLost:Connect(function()
script.Parent.Text = "<i>"..script.Parent.Text.."</i>"
end)

I’m pretty sure you have to use a script to use stuff like Italics.

TextBox.ClearTextOnFocus = false

Not sure if this is what you’re asking for.
https://developer.roblox.com/en-us/api-reference/property/TextBox/ClearTextOnFocus

what he meant is
when he types in the textbox he wants to keep the italic rich text on

Oh, then he should use GetPropertyChangedSignal("Text") to detect when the textbox’s text changes.

already tried to do that earlier, but didn’t work for me.

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
script.Parent.Text = "<i>"..script.Parent.Text.."</i>"
end)

whenever the text changes once the text will be spammed with the italic rich text <i>
100% because its detecting whenever this "<i>"..script.Parent.Text.."</i>" is changing too.

local Script = script
local TextBox = Script.Parent

local Connection

local function OnTextBoxChanged()
	if Connection then Connection:Disconnect() end
	TextBox.Text = string.gsub(TextBox.Text, "<i>", "")
	TextBox.Text = string.gsub(TextBox.Text, "</i>", "")
	TextBox.Text = "<i>"..TextBox.Text.."</i>"
	TextBox.CursorPosition = string.len(TextBox.Text) - 3
	Connection = TextBox:GetPropertyChangedSignal("Text"):Connect(OnTextBoxChanged)
end

OnTextBoxChanged()

Apparently formatting isn’t applied until the textbox’s focus is lost anyway, this would work otherwise.

1 Like