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

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

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

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!

1 comment

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.

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