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 » Scripting Helpers
Home Search
 

How would I check if the first letter of the value is a?

Previous Thread :: Next Thread 
IlIll is not online. IlIll
Joined: 28 Aug 2011
Total Posts: 896
01 Aug 2012 12:56 AM
I have a bunch of values and in my script I use GetChildren() to search for the values with the number 1, 2 or 3.. but I'm thinking of changing it so that it searches for the first letter of the value. Like the value would be a60 or a12. I want to know how I can check if the first letter of the value is a because I'll have other values with other letters like b and c. Sorry if you're confused... I'm half asleep.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Aug 2012 01:01 AM
letter = "apples"
if letter:sub(letter,1,1) == "a" then
print("ye")
end

Tired too you know :3
Report Abuse
IlIll is not online. IlIll
Joined: 28 Aug 2011
Total Posts: 896
01 Aug 2012 01:01 AM
Would I be able to use string.gmatch?
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Aug 2012 01:05 AM
letter = "apples"
for all in letter:gmatch("%l+") do
if all == "a" then
print("ye")
end
end

I'm tired, maybe? Probably not because I'm getting sleepy :3
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Aug 2012 01:08 AM
I would just use string.sub()
Report Abuse
IlIll is not online. IlIll
Joined: 28 Aug 2011
Total Posts: 896
01 Aug 2012 01:08 AM
Thanks! Have a nice rest... when you do sleep.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Aug 2012 01:10 AM
In like another hour XP

It's bad health, but I'm skinny and have coffee. I'm already healthy XP
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
01 Aug 2012 01:16 AM
string.sub(msg,1,2) is the advanced faster running one (tested)

msg:sub(1,2) is the simple medium running one (tested)
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
01 Aug 2012 01:19 AM
^

Premature Optimization.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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