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: Quick Question of string.Match

Previous Thread :: Next Thread 
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 12:00 AM
So, I was trying to get a value of true or false using string.match("hey!","h") but it just printed h. Is there some sort of way I can check if a certain letter is in a sentence/number?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jan 2017 12:01 AM
It returns nil if it isn't, so just check if it's not nil
Report Abuse
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 12:14 AM
Thanks, I will check if that works!
Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
20 Jan 2017 12:15 AM
How could that possibly not work?


Report Abuse
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 12:21 AM
When I do this it returns false? print (string.match(numbar2/2, '.')== nil) btw numbar2 is 8
Report Abuse
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 12:22 AM
I don't know..
Report Abuse
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 12:24 AM
Nevermind disregard this. I'm dumb. Thanks for the help
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
20 Jan 2017 12:24 AM
Of course it returns false:

i) b/c 4 is not string, it's a number
ii) even if it were, "4" and "." have nothing in common, so "string.match(4,".")==true" is not a true statement, it's false.
Report Abuse
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 12:25 AM
I meant to do ~= nil when I was doing == nil
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
20 Jan 2017 12:27 AM
unless i'm wrong that should indeed throw true
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jan 2017 12:49 AM
You're wrong
And you're also wrong about being wrong

string.match returns either anything matches or nil
It won't return true or false
But matching with "." will return the first character because . is a special character - it won't be true or false.
Report Abuse
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 12:57 AM
Is there any way of finding if a number is a decimal after being divided, etc.. ? Because that is basically what I'm trying to do
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jan 2017 12:59 AM
if num % 1 ~= 0 then
print("has a remainder")
end
Report Abuse
MrF_kFace1 is not online. MrF_kFace1
Joined: 08 May 2016
Total Posts: 78
20 Jan 2017 01:00 AM
Thanks, I was annoyed because I couldn't find this :P
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
20 Jan 2017 01:35 AM
@cntkillme

You're wrong, read his code

he had a logical assertion being checked, not simply 'string.match'

hence, true/false would be returned, not true/nil
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
20 Jan 2017 01:36 AM
rather, string/nil
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
20 Jan 2017 01:40 AM
i retract that, ############ is right
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
20 Jan 2017 01:40 AM
@cntkillme
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
20 Jan 2017 01:43 AM
don't you just love the filter
Report Abuse
mani_fold is not online. mani_fold
Joined: 23 Dec 2016
Total Posts: 546
20 Jan 2017 01:56 AM
well i stylized your name in a way that i could see being a bit saucy
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