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
 

Re: What the string.match

Previous Thread :: Next Thread 
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 11:03 AM
I don't get why the string.match part gives me nil. . . Everything is defined.

for i, v in pairs(Game.Players:GetPlayers()) do
print(v.Name:lower())
print(Target)
print(string.match(v.Name:lower(), Target))
end

Output:

> player1
> player
> nil --???

¤¤ †KMXD† ¤¤
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 11:14 AM
aide-moi, s'il vous plait

¤¤ †KMXD† ¤¤
Report Abuse
TheGamer101 is not online. TheGamer101
Joined: 14 Feb 2009
Total Posts: 11943
04 Nov 2012 11:17 AM
No idea why it wouldn't work, considering this works.
print(string.match("player1", "player"))
>player


Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
04 Nov 2012 11:20 AM
Full script? o.O
Report Abuse
TehChikenHater is not online. TehChikenHater
Joined: 11 Jun 2012
Total Posts: 497
04 Nov 2012 11:23 AM
Unless Target is a string, that won't work. If you're doing Mouse.Target, do this:

for i, v in pairs(Game.Players:GetPlayers()) do
  print(v.Name:lower())
  print(Target)
  print(string.match(v.Name:lower(), Target.Name)) --Assuming this is declared: "local Target=Mouse.Target"
end
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 11:33 AM
@Gamer

Yup, I even confirmed it should've worked with that also.

@teh

Yes, it's a string of course.

¤¤ †KMXD† ¤¤
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
04 Nov 2012 11:34 AM
Post a list of what you are matching :)

string.match returns nil when there is no match. In an item in the list there must be no "player" in the string.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 11:42 AM
I know. I want to match a player's name, in this case, "player1", with whatever I put in the function (target), in this case "player".

¤¤ †KMXD† ¤¤
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 11:43 AM
Also, as I've done so by printing, neither of the two I want to match are nil, so I don't get why it doesn't match. They're both all lowercase, and have no spaces at the end.

¤¤ †KMXD† ¤¤
Report Abuse
PlusJon is not online. PlusJon
Joined: 27 Sep 2012
Total Posts: 1522
04 Nov 2012 11:49 AM
Please add this to your script and tell me the output of this:

print(type(Target))
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 11:55 AM
string. I'm pretty sure I know what strings are. . . Why else would I be using string.match?

¤¤ †KMXD† ¤¤
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
04 Nov 2012 11:58 AM
Full script? C:
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 12:01 PM
I don't see how it's necessary as we already established they're both strings that should be matched. Besides, my script is pretty messy, and could be hard to follow if you're not good with string manipulation.


¤¤ †KMXD† ¤¤
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 12:13 PM
    ROBLOX.Forum["Roblox Game"]["Scripting Helpers"]["What the string.match"]:Bump()

¤¤ †KMXD† ¤¤
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
04 Nov 2012 12:16 PM
There's nothing wrong with this code. .-.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 12:26 PM
That's the most frustrating part, at least with a syntax error, I could fix it. I swear Roblox is just trolling me.

¤¤ †KMXD† ¤¤
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
04 Nov 2012 02:20 PM
Yea it's not like there could be a problem with any other parts of the code.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 05:37 PM
Eh, I might as well give up on this thing.

¤¤ †KMXD† ¤¤
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 Nov 2012 06:25 PM
for i, v in pairs(Game.Players:GetPlayers()) do
print(v.Name:lower())
print(Target)
print(string.match(v.Name:lower(), ("(%s)"):format(Target)))
end



:)
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 09:50 PM
No dice, still returns nil, Agent. :(

¤¤ †KMXD† ¤¤
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
04 Nov 2012 09:57 PM
Yea guys, there's totally NO WAY that there could be a problem in the other part of the script, right?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 09:59 PM
Even if there was, the code could easily be converted to be stand-alone, and still not be working as expected. Plus, it printed the two strings I was trying to match, and those two are strings, that SHOULD not return nil.

¤¤ †KMXD† ¤¤
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
04 Nov 2012 10:04 PM
Well this works:
Target = "player"
wait(40)
for i, v in pairs(Game.Players:GetPlayers()) do
print(v.Name:lower())
print(Target)
print(string.match(v.Name:lower(), Target))
end
Soooo
Yea.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
04 Nov 2012 10:05 PM
Really? It's not like we haven't establish the code *should* be working or anything.

¤¤ †KMXD† ¤¤
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
04 Nov 2012 10:06 PM
ikr
roblox must hate you :(
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