Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Convert multiline strings to single line?

Asked by 6 years ago
Edited 6 years ago

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)
0
There's a property for that in the TextBox. User#19524 175 — 6y
0
The text from the TextBox is sent to a TextLabel. I still want the TextBox to be multi-lined. ICosmicReaver 32 — 6y
0
Again, the TextBox has a property for this. User#19524 175 — 6y
0
Called? If you're talking about MultiLine, its already set to true. ICosmicReaver 32 — 6y
View all comments (2 more)
0
MultiLine is the property. If it's true, your problem is fixed. User#19524 175 — 6y
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. ICosmicReaver 32 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

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.

Ad

Answer this question