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

Convert multiline strings to single line?

I have a multiline text box that players can type in. When they press a button it is sent to the main chat functioning as an in-game copy and paste.

However, the text that is sent stays multiline. Instead I want it to be converted to single line because currently only the first line can be read.

Edit: The text from the TextBox is sent to a TextLabel. I still want the TextBox to be multi-lined.

sp.MouseButton1Click:connect(function()
if messageBox.Text ~= '' and string.len(messageBox.Text) ~= 0 then
event:FireServer(messageBox.Text) -- I want the textbox to remain multiline but change the variable sent to a single line string
end
end)

6 comments

0

There's a property for that in the TextBox.

0

The text from the TextBox is sent to a TextLabel. I still want the TextBox to be multi-lined.

0

Again, the TextBox has a property for this.

0

Called? If you're talking about MultiLine, its already set to true.

0

MultiLine is the property. If it's true, your problem is fixed.

0

Except thats not the problem. The text from the TextBox goes to a TextLabel. TextLabels don't have MultiLine but the MultiLine still occurs when it shouldn't. So when passing the variable I want to convert it to single line using a string manipulation. Sorry if I'm confusing.

1 answer

I figured it out but for anyone that may come across this problem.

string.gsub(msg, "\n", "")

White space/ MultiLine is represented by \n. If you replace all of those with nothing, the whitespace will be removed.

Uses: When pasting in a custom chat system, removes all the white space that may cause the text to be unreadable.

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