| |
|
|
| 02 Jun 2015 09:19 AM |
Number of letters:
function LettersInString(str) for i,v in str:gmatch("%a") do n = n + 1 do return n end
print(LettersInString(TextBox.Text)
Number of characters:
print(#TextBox.Text) |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 09:20 AM |
Sorry, thought I was in a pairs loop for a sec there, fix:
function LettersInString(str) for letter in str:gmatch("%a") do n = n + 1 do return n end
print(LettersInString(TextBox.Text) |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 09:21 AM |
Oh wait I figured out an easier way lol
if #Chatbar.Text >= 2 then
Reason im doing this is because Goulstem said prevent empty messages. |
|
|
| Report Abuse |
|
|
Intern33t
|
  |
| Joined: 19 Nov 2010 |
| Total Posts: 1530 |
|
|
| 02 Jun 2015 09:34 AM |
#"String" is correct. Dont use len
~ᵂʰᵒ ᵃʳᵉ ʸᵒᵘ ᵗᵒᵈᵃʸ﹖~ |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 10:41 AM |
Don't*
Next time be more specific if you want letters or characters...
btw using # or len people could just send spaces/tabs, try this:
string.format(TextBox.Text:match( "^%s*(.-)%s*$"))
print(#TextBox.Text) |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 10:52 AM |
Warspy, your ends are unbalanced.
local function LCount(String) local N = 0 String:gsub("%a", function() N = N + 1 end) end |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
| |
|
|
| 02 Jun 2015 10:55 AM |
M1ne is better and shorter
#TextBox.text |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 01:29 PM |
I typed do instead of end, #MyMistake
lol. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 01:34 PM |
Here is the best way
local TextBox = script.Parent
function GetLetters() local Tab = {} for i = 1,string.len(TextBox.Text) if not tonumber(string.sub(TextBox.Text,i)) then table.insert(Tab,"A letter") end end return #Tab end |
|
|
| Report Abuse |
|
|
| |
|
|
| 02 Jun 2015 01:37 PM |
| I gave you a working function... |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 01:43 PM |
One that takes longer.
Also i want my account back. |
|
|
| Report Abuse |
|
|
|
| 02 Jun 2015 01:43 PM |
local TextBox = script.Parent --This is not variable worthy
function GetLetters() --A string should get inputted as an argument local Tab = {} for i = 1,string.len(TextBox.Text) --Use # not string.len --You forgot do if not tonumber(string.sub(TextBox.Text,i)) then --TextBox.Text:sub(i) would look better --You checked if everything after and including the current index was not a number, I believe you meant TextBox.Text, i, i table.insert(Tab,"A letter") --You didn't insert the letter, you inserted "A letter" end end return #Tab end
--You didn't call it
fish, that doesn't look like a "working function" to me. |
|
|
| Report Abuse |
|
|