generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How would I get the num of letters in a textbox..

Previous Thread :: Next Thread 
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
02 Jun 2015 09:13 AM
string.len?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
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 is not online. Intern33t
Joined: 19 Nov 2010
Total Posts: 1530
02 Jun 2015 09:34 AM
#"String" is correct. Dont use len

~ᵂʰᵒ ᵃʳᵉ ʸᵒᵘ ᵗᵒᵈᵃʸ﹖~
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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 is not online. booing
Joined: 04 May 2009
Total Posts: 6594
02 Jun 2015 10:55 AM
Cause Waspy Cant Script.
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
02 Jun 2015 10:55 AM
M1ne is better
and shorter

#TextBox.text
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
02 Jun 2015 01:29 PM
I typed do instead of end, #MyMistake

lol.
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
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
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
02 Jun 2015 01:35 PM
No thx gg no re re
Report Abuse
fishguy100 is not online. fishguy100
Joined: 16 Feb 2013
Total Posts: 3679
02 Jun 2015 01:37 PM
I gave you a working function...
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
02 Jun 2015 01:43 PM
One that takes longer.

Also i want my account back.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image