thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 21 Nov 2012 05:55 PM |
I'm currently working on a Command Script for a group I'm in, but I have quite a few tables, and I was wondering if is possible to use one, global method than to create multiple methods for each table. I looked into it, and it sometimes works, sometimes doesn't. Code: -- This method sometimes returns nil even if I enter the same exact value and table name local users = { "thumper10", "DeltaSabre" } local banned = { "Shedletsky" }
function isInTable(tableName, stringToFind) local s = stringToFind if (tableName == nil) then return nil end local t = tableName for a = 1, #t do if (s:lower() == t[a]:lower()) then return true end return false end end
OUTPUT: print(isInTable(users, "thumper10")) > true FIVE OR SO TIMES LATER: print(isInTable(users, "thumper10")) > nil
Any idea what's causing this? Thanks in advance!
= C# All Day Everyday = |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2012 06:11 PM |
function isInTable(tableName, stringToFind) local s = stringToFind if (tableName == nil) then return nil end local t = tableName for a = 1, #t do if (s:lower() == t[a]:lower()) then return true end end return false end
? |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 21 Nov 2012 06:17 PM |
^ That did it. I guess having the return false there was causing random issues. Thank you.
= C# All Day Everyday = |
|
|
| Report Abuse |
|
|
|
| 21 Nov 2012 07:34 PM |
| It doesn't make sense though. It should still have returned nil. o.o |
|
|
| Report Abuse |
|
|
thumper10
|
  |
| Joined: 17 Apr 2009 |
| Total Posts: 3304 |
|
|
| 21 Nov 2012 07:53 PM |
I think ROBLOX is playing mind games...
= C# All Day Everyday = |
|
|
| Report Abuse |
|
|