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

Is it possible to get the amount of lines on a TextBox?

Asked by 3 years ago

I am going for a Monaco type theme, where I place a number next to the text to make referencing errors easier.

The reason I want to know is because I am making a game for beginner scripting, where you can join to learn the basics and try them yourself.

1 answer

Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
3 years ago

What I would personally do is to make a different TextBox for each line,place them in a Folder and use Folder:GetChildren() to count the amount of lines with text in them.

Example:

local lines = script.Parent.Folder

local count = 0

for _, line in pairs(lines:GetChildren()) do
    if line:IsA("TextBox") then
        if line.Text ~= "" then
            count = count + 1
        end
    end

    script.Parent.LineCount.Text = tostring(count)
end

Hope this helps!

0
Sadly, this does not work for what I am trying to pull off. I would use this method, but I need to check the text they put in as one string. DetectiveRaie 193 — 3y
Ad

Answer this question