This is my first time doing something using strings like this, did i do good?
local textbox = script.Parent.TextBox
local linecounter = script.Parent["Line Counter"]
textbox.Changed:Connect(function()
local str = textbox.Text
local _,count = str:gsub('\n','\n')
local newcount = count + 1
--check if value is the same
if not linecounter.Text:find(newcount) then
-- set the max line he/she has
topcount = newcount
-- go through the new lines
for i = 1,topcount,1 do
local prevtext = linecounter.Text
-- set new lines
if not linecounter.Text:find(i) then
linecounter.Text = tostring(prevtext..i..'\n')
end
end
-- check if he/she deleted a line
else if topcount ~= newcount and topcount ~= nil then
-- set text to nil
linecounter.Text = ""
-- set the max lines to the new lines
topcount = newcount
for i = 1,topcount,1 do
-- set new lines
linecounter.Text = tostring(linecounter.Text..i..'\n')
end
end
end
end)