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

How to read a specific line from a textbox?

Let's say I had this in a textbox or string:

Hello!

World

This is

a string

that doesn't

exist!

If I wanted to, say, print line 4, how would I go about doing that? There doesn't seem to be any straightforward way of doing this.

1 answer

✓ Accepted answer

You can use string.split to split new lines into seperate parts, then getting the 4th result.

Example:

local str = [[
hello

ok

yes

wanted
]]

print(string.split(str, "\n")[4])
-- \n meaning new line

string.split(<string> what string to split, <string> what part to split)

This should give a table containg

[1] = hello [2] = ok [3] = yes [4] = wanted

As string.split returns a table.

1 comment

0

good explanation

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